Hello,
I have a script that I am using to manage a large list of stale user accounts. I have the DN for each of the targeted accounts. I have been unable to figure out how to pass this through my foreach loop and change from the DN to the SamAccountName. Here is a snippet from the script that includes the foreach loop. I am receiving an error that the -Identity argument is null.
I am hoping that someone will be able to show me what I am missing.
Powershell
$Users=Import-Csv-Path'C:\ps\staleusers.csv'foreach($Userin$Users){$User=Get-ADUser$User.DistinguishedName-PropertiesSamAccountName,Description,MemberOfAdd-ADGroupMember'CN=RetiredUsers,OU=RetiredUsers,DC=domain,DC=com'-Member$user.SamAccountNameSet-PrimaryGroup$User.SamAccountNameSet-ADUser$User.SamAccountName-Description"ACCOUNT DISABLED AND MOVED DUE TO...