I am very new to powershell and am running into a road block I can not figure out. I have a CSV with a list of 380 user accounts with one white space behind their samaccount name. This is on a Windows 2003 server that has PSv2 and Quest.Activeroles.admanagement This is what I have so far
`add-pssnapin quest.activeroles.admanagement
get-PSSnapin Quest.ActiveRoles.ADManagement
Import-Csv "C:\Documents and Settings\%user%\Desktop\withspaces2.csv" | ForEach{ Set-QADUser $_.sAMAccountName.Replace(' ',"").Replace("\t","") }`
It is removing the white space for the first user but doing nothing to the others here is what the Errors looks like.
Name Type DN
---- ---- --
ABPR user CN=ABPR,CN=Users,DC=DRIVERS,DC=...
ADDJ user CN=ADDJ,CN=Users,DC=DRIVERS,DC=... Set-QADUser : Ambiguous identity: ALLMA.
At line:3 char:12
- Set-QADUser <<<< $_.sAMAccountName.Replace(' ',"").Replace("\t","")
- CategoryInfo : NotSpecified: (:) [Set-QADUser], IdentityException
- FullyQualifiedErrorId : Quest.ActiveRoles.ArsPowerShellSnapIn.BusinessLogi
c.IdentityException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets
.SetUserCmdlet
ALLR user CN=ALLR,CN=Users,DC=DRIVERS,DC=...
ALLS user CN=ALLS,CN=Users,DC=DRIVERS,DC=...
Set-QADUser : Ambiguous identity: AMAB.
At line:3 char:12
- Set-QADUser <<<< $_.sAMAccountName.Replace(' ',"").Replace("\t","")
- CategoryInfo : NotSpecified: (:) [Set-QADUser], IdentityException
- FullyQualifiedErrorId : Quest.ActiveRoles.ArsPowerShellSnapIn.BusinessLogi
c.IdentityException,Quest.ActiveRoles.ArsPowerShellSnapIn.Powershell.Cmdlets
.SetUserCmdlet