Albert Widjaja
asked on
Powershell script to list user status based on CSV file not working due to apostrophe (Irish surname) !
Hi All,
Can anyone here please assist me in modifying the PowerShell script below so that it works for the Irish surname or any surname with the Apostrophe ?
Script:
The script is comparing the name of the people in the CSV file
CSV File format:
with the Active Directory users and the result will be exported into another CSV file with Display Name,samAccountName,accoun t status column.
Any help would be greatly appreciated.
Thanks.
Can anyone here please assist me in modifying the PowerShell script below so that it works for the Irish surname or any surname with the Apostrophe ?
Script:
$names = Import-CSV "C:\test\names.csv"
$outFile = "C:\test\status.csv"
if (Test-Path $outFile) {Remove-Item $outFile -Force}
Add-Content -Path $outFile -Value "name,samaccountname,enabled"
foreach ($name in $names)
{
$result = Get-ADUser -filter "Surname -eq '$($name.surname)' -and GivenName -eq '$($name.firstname)'" -Properties * | select enabled,samaccountname,displayname
Add-Content -Path $outFile -Value "$($result.displayname),$($result.samaccountname),$($result.enabled)"
}
The script is comparing the name of the people in the CSV file
CSV File format:
First Name, Last Name
Jason, Smith
April, O'Neill
Franky, O'Hara
Lisa,Auchterlonie-Crooks
...
with the Active Directory users and the result will be exported into another CSV file with Display Name,samAccountName,accoun
Any help would be greatly appreciated.
Thanks.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER