0
Dear colleagues,
I need to read a CSV file and filter the users within the AD with the information contained in the CSV. I need to compare the CSV field with the Userprincipalname inside the AD.
My script is like this:
Import-Module ActiveDirectory
$Users = "C:\Script\leiaute.csv"
Import-CSV $Users -Header UserPrincipalName | Foreach-Object {
Get-ADUser -Filter "UserPrincipalName -like '$_'" -SearchBase 'OU=BHZ,OU=MG,DC=elv,DC=intranet' | % {Set-ADUser -Identity $_.’UserPrincipalName’ -Enabled $false}
Does not return me any error message, but does not perform the desired task.