I have been racking my brain trying to figure out what every post I read says is straightforward is not working for me. Simply put I have a txt file which is generated by another department that has UPNs in it. We have multiple realms in our domain due to migration from a non-AD directory.
While the Get-ADUser works on a line by itself it fails in the loop. My research leads me to believe am not passing my loop variable correctly so I have tried
Thanks for the help. I’m still getting errors. I think it’s because my file is using UPNs not samAccountNames with your approach. Due to having mixed realms in our environment, I am leaving room for the same username at different realms. I am using the UPN, because I know they are unique.
add-adgroupmember : Cannot find an object with identity: 'user@domain.edu ’ under: ‘DC=domain,DC=edu’.
Hi Kvprasoon,
Thanks for the suggestion. I didn’t mention that the file gets generated on a Linux system and transfered to Windows. When I looked at the file in Notepad it looks like a long line with spaces between values and in Wordpad looks normal. I tried using .trim() but that didn’t solve my issue. Closer inspection of the input file revealed spaces and Unix not Windows new line characters.
Working now. Thanks for pointing me in the right direction.
That’s strange. Unix input text files work ok for me in windows powershell scripts. My only problem was “unicode” text produced by Out-File and Infoblox.