Mücahit Koç
asked on
Active Directory - User Telephone Number copy to ipPhone Atttribute
I am trying to copy the last 4 characters of the phone number with the following scenario, but I get an error. Help please :(
Error :
You cannot call a method on a null-valued expression.
At line:3 char:5
+ $phoneNumber = $_.OfficePhone.Substring($ _.OfficePh one.Length - 4,4)
Error :
You cannot call a method on a null-valued expression.
At line:3 char:5
+ $phoneNumber = $_.OfficePhone.Substring($
Get-ADUser -Filter * -SearchBase 'OU=Test 1,DC=domain,DC=com' -Properties OfficePhone | ForEach {
$phoneNumber = $_.OfficePhone.Substring($_.OfficePhone.Length - 4, 4)
Set-ADUser -Identity $_.SamAccountName -Replace @{ipPhone=$phoneNumber}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER