Advertisement
Guest User

Untitled

a guest
Sep 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $OU = ''
  2. $userpool = Get-ADUser -Filter * -SearchBase $OU -Properties mobile | Select-Object SamAccountName, Mobile
  3.  
  4. foreach ($user in $userpool)
  5.   {
  6.     if ($user.mobile[0] -eq '8')
  7.       {
  8.         $user.mobile = '+7' + $user.mobile.Substring(1,$user.mobile.Length - 1)
  9.       }
  10.     if ($user.SamAccountName.Length -ge 2)
  11.       {
  12.         $user.mobile = $user.mobile -replace ('[^\w+]','')
  13.         $goodNumber = $user.mobile.Insert(2," ").Insert(6, " ").Insert(10, " ")
  14.         Set-ADUser $user.SamAccountName -Replace @{mobile=$goodNumber}
  15.       }
  16.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement