Hi,
Although you can read Excel files, if possible I'd suggest asking for the info as a CSV or saving to CSV yourself as its a bit easier to work with. With the CSV in the following format:
uiddn,nids
"uid=uid12345,cn=abc,cn=def,dc=xyx",7_54321
"uid=uid6789,cn=abc,cn=def,dc=xyx",5_9876
This code should get you fairly close to what your after if my understanding of your request is right. I've done something very similar to create config files to create new users on a firewall for VPN accounts:
$InputCSV = "C:\uiddn.csv"
$Output_Folder = "C:\"
Import-csv -path $InputCSV | ForEach {
"dn: $($_.uiddn)" | Out-File -FilePath "$($Output_Folder)removenid.ldif" -Append
"changetype: modify" | Out-File -FilePath "$($Output_Folder)removenid.ldif" -Append
"delete: nIds" | Out-File -FilePath "$($Output_Folder)removenid.ldif" -Append
"nIds: $($_.nids)" | Out-File -FilePath "$($Output_Folder)removenid.ldif" -Append
"-" | Out-File -FilePath "$($Output_Folder)removenid.ldif" -Append
"n: cn=ghk,cn=klm,cn=opu,dc=xyx" | Out-File -FilePath "$($Output_Folder)groupremoval.ldif" -Append
"changetype: modify" | Out-File -FilePath "$($Output_Folder)groupremoval.ldif" -Append
"delete: member" | Out-File -FilePath "$($Output_Folder)groupremoval.ldif" -Append
"member: $($_.uiddn)" | Out-File -FilePath "$($Output_Folder)groupremoval.ldif" -Append
"-" | Out-File -FilePath "$($Output_Folder)groupremoval.ldif" -Append
}
The lines with "-" can be changed to just "" if you want a blank line - I'm not familiar with the specifics of the ldif format so I'm not sure if a trailing - in the file causes issues or not.