Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Sunday, May 17, 2015 8:26 AM
Hello,
I have a requirement to change the Telephone Number of existing staff. Currently the staff has their officeNumber followed by Ext number.
I can export the existing telephone number and amend the CSV file to match the new number by this command;
Get-QADUser -SearchRoot 'DomainName.com/DomainUsers/Staff' | Select-Object SamAccountName, TelephoneNumber | Expo
rt-Csv C:\Scripts\UsersExtension.csv
The CSV list will be updated to match the new telephone number and will use the updated list to amend the user's telephone number.
I have used the below command but it doesn't work;
Import-Csv c:\Scripts\UsersExtension.csv | ForEach-Object {Set-QADUser -Identity $_.sAMAccountName -ObjectAttributes @{extensionAttribute $_.TelephoneNumber}
Any help to get this done, highly appreciated.
Regards,
All replies (3)
Sunday, May 17, 2015 12:14 PM ✅Answered
Solved since 1 hour ago...
Import-Csv C:\Scripts\userlist.csv | ForEach-Object {Set-QADUser $_.samAccountName -Phonenumber $_.Telephonenumber}
Thanks,
Sunday, May 17, 2015 8:52 AM
I have tried the below loop and it doesn't work :(
$SamAccountName = Get-Content -Path "C:\Scripts\Userlist.csv"
foreach ($user in $SamAccountName)
{
Set-QADUser -Identity $User -Phonenumber $_.TelephoneNumber
}
Sunday, May 17, 2015 12:12 PM
What does that mean - "it doesn't work".
In both exampkes you are trying to change different attriburtes. What is it that you want to change?
Start by looking at the help for Set-Qaduser. Next spend sometime leaning what a CSV is and how to use it. After that you need to look at how PowerShell manages Csv files and how too use them in a loop.
Import-Csv C:\Scripts\Userlist.csv | %{Set-QADUser -Identity$_.SamAccountName -Phonenumber$_.TelephoneNumber}
Don't guess. Read the documentation.
\(ツ)_/