Forum Discussion
charlie4872
Oct 29, 2021Brass Contributor
Need to change bulk users Samaccountname to uppercase
Hello I am trying to get this script to update a list of samaccountname from lowercase to uppercase. We have an application that has issues with lowercase. I have tried the below and it is giving me ...
- Oct 29, 2021Here's a working example:
$users = Import-Csv .\users.csv
$users | % { Set-ADUser $_.SamAccountName -SamAccountName $_.SamAccountName.ToLower() }
charlie4872
Brass Contributor
Thanks for the reply Vasil. When creating the .csv file and adding the column. Running the script now gives me the below error.
set-aduser : Object reference not set to an instance of an object
At C:\Scripts\Domain MIgration\TEST.ps1:3 char:1
+ set-aduser $user -SamAccountName $user.samaccountname.toupper()
set-aduser : Object reference not set to an instance of an object
At C:\Scripts\Domain MIgration\TEST.ps1:3 char:1
+ set-aduser $user -SamAccountName $user.samaccountname.toupper()
VasilMichev
Oct 29, 2021MVP
Here's a working example:
$users = Import-Csv .\users.csv
$users | % { Set-ADUser $_.SamAccountName -SamAccountName $_.SamAccountName.ToLower() }
$users = Import-Csv .\users.csv
$users | % { Set-ADUser $_.SamAccountName -SamAccountName $_.SamAccountName.ToLower() }
- charlie4872Oct 29, 2021Brass ContributorThat worked. Thanks for your help Vasil!