[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2014-08-04
2
Medium Priority
?
1,515 Views
Last Modified: 2014-08-04
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
0
Comment
Question by:SAIMSKY ADMIN
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 40238689
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

0
 

Author Closing Comment

by:SAIMSKY ADMIN
ID: 40238826
Thanks
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Let's recap what we learned from yesterday's Skyport Systems webinar.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Screencast - Getting to Know the Pipeline

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question