Hi,
We have an ADExport.csv file which overnight imports users into Assyst via ETM.
Sometimes, a user fails to import so we manually have to import that user via ETM.
I’ve written a basic PowerShell script which prompts us to enter in the Email address of the user that has failed to import. Once the email address has been entered, the script then searches for that user in the ADExport.csv file. Once the user is found in the file, it copies the following file headers into a new .csv file:
"sAMAccountName","userPrincipalName","SID","GivenName","Description","sn","physicalDeliveryOfficeName","Department","mail","telephoneNumber","userAccountControl","MobilePhone","Manager","ManagerName","ManagersAMAccountName","extensionAttribute11","DistinguishedName"
The script then copies the users info found in the ADExport.csv file then pastes it into the new .csv file created above. I’ve confirmed each header has the correct info assigned.
When I import the new .csv into ETM, it shows the following error message:
If I do the exact same thing manually, the .csv file imports without any issues.
Manual Process:
- Copy the headers from the ADExport.csv file into a new .csv file
- Copy the users info from the ADExport.csv file into a new .csv file
- Successfully imports into ETM
I’ve done a hexadecimal file comparison and the two files are identical but for some reason, the .csv created via the PowerShell script fails to import.
PowerShell script:
Do {
#Prompt user for input
$EmailAddressOfUser = Read-Host -Prompt "Please enter the user's email address"
""
} Until ($EmailAddressOfUser)
Do {
#This is the ADExport.csv file the script will search for the user in.
$filename = "\\Location\ADExport.csv"
} Until ($filename)
#Save file with the email address in the file name.
$saveOutputFileAs = "ADExport_$EmailAddressOfUser.csv"
#Search for sAMAccountName header in ADExport.csv
$ValueToSearchFor = "sAMAccountName"
$Output = select-string -path "$filename" -Pattern "$ValueToSearchFor"
$Output.line | out-file \\Location\$saveOutputFileAs -append
$Output = select-string -path "$filename" -Pattern "$EmailAddressOfUser"
$Output.line | out-file \\Location\$saveOutputFileAs -append
#End of script
The script creates the file with the data I need but I can’t figure out why It’s failing to import into ETM.
Would appreciate any help on this! :-)
Kind regards,
Danyal