Powershell Script - replace information of Homephone with Pager field in AD.

SAIMSKY ADMIN
SAIMSKY ADMIN used Ask the Experts™
on
I wan to update AD > User> Properties > Telephone Information.

need to replace Home phone with Pager

Import-Module ActiveDirectory            
           
# Find all accounts with Pager
# Copy that value into Description            
Get-ADUser -LDAPFilter '(Pager=*)' -Properties homephone, pager |            
 Select-Object * -First 5 |            
 ForEach-Object {Set-ADObject -Identity $_.DistinguishedName
  -Replace @{homephone=$($_.pager)}}


----------------------------------------------------------

Getting this error

 
The term '-Replace' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:8 char:11
+   -Replace <<<<  @{homephone=$($_.pager)}}
    + CategoryInfo          : ObjectNotFound: (-Replace:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


Please advise
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
IT Infrastructure Architect
Commented:
Hope you are typing the Set-ADObject command and -Replace parameter in single line..
#Find all accounts with Pager
# Copy that value into Description            
Get-ADUser -LDAPFilter '(Pager=*)' -Properties homephone, pager |            
Select-Object * -First 5 |
ForEach-Object {Set-ADObject -Identity $_.DistinguishedName -Replace @{homephone=$($_.pager)}}

Open in new window

SAIMSKY ADMINSYS ADMIN

Author

Commented:
Thanks

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial