I am encountering a weird error and its boggling my mind. Can you powershell experts please show me what i am doing wrong. I am trying to put together a foreach statement that will readd AD groups to an AD User object/Member. So whats odd is that if i used the below PS code it works manually but does not work with variables and the foreach code below. It errors our stating cant find identity. But why when i manually input the same identity that is looping through it errors our. So for example if i type:
It works just fine.. I verify and the AD Group is added to member 1078477
But when i insert this with variables and a foreach statement it states it cant find the identity? I verify that whats looping through is correct by executing the variable by itself.
Ive been playing with foreach statements all day trying to finetune my PS skills and understand the difference between foreach and Foreach-Object and Get-Content and Import-CSV for my own knowledge.