Error when identifying user login "-Identity"

Asked

Viewed 49 times

1

I made this simple script to remove a particular group from AD users via .csv but is accusing error that the $_.user has not been identified or is empty.

Import-Csv -Path "C:\Users\antonio.costa\Documents\office365\vpn.csv"

ForEach {
Remove-ADPrincipalGroupMembership -Identity $_.user -MemberOf "Acesso_vpn"
}
break

This break I added to see it stopping on the screen, but besides giving the error and not stop, already closes soon.

  • Read on: https://docs.microsoft.com/pt-br/powershell/scripting/learn/understanding-the-powershell-pipeline?view=powershell-6

1 answer

1


You have that task mentioned in that article/link: https://www.petenetlive.com/KB/Article/0001475



Import-Csv -Path "C:\Users\antonio.costa\Documents\office365\vpn.csv" | ForEach-Object {Remove-ADGroupMember -Identity "Acesso_vpn" -Member $_.'User-Name' -Confirm:$false }

# ou #

ipcsv -Path "C:\Users\antonio.costa\Documents\office365\vpn.csv" | % {Remove-ADGroupMember -Identity "Acesso_vpn" -Member $_.'User-Name' -Confirm:$false }

It is suggested to visit this question of the Soen: Q29148462


Browser other questions tagged

You are not signed in. Login or sign up in order to post.