0

Here is my problem:

I have a list of Numbers: 183 rows in total (in csv file or txt file)

437735121495357

323099286491547

453369992736587

556548989085878

I need to take one row of 15 digits and replace the variable: %VariableUID in this file, continually to all rows of digits and variables have been replaced

dn: uid=%VariableUID, ou=People, o=aims.edu, o=cp

changetype: modify
delete: pdsRole
pdsRole: generic
-
add: pdsRole
pdsRole: student

dn: uid=%VariableUID, ou=People, o=aims.edu, o=cp

changetype: modify
delete: pdsRole
pdsRole: generic
-
add: pdsRole
pdsRole: student

dn: uid=%VariableUID, ou=People, o=aims.edu, o=cp
changetype: modify
delete: pdsRole
pdsRole: generic

each %VariableUID would be replaced by the next set of digits

0

1 Answer 1

0

So after more and more searching I ended up answer my own question with a powershell script. I wasn't able to modifiy an existing template..but I was able to use powershell script to format the txt file to replace my template:

#Location of Source File and Alias
$Source= gc "C:\Users\amoore19\Desktop\LDAP\ui-3rd-party.txt"
#takes each row in the Source File and replace the variable: $ouid in the following format
foreach ($ouid in $Source)
{
write-output "
dn: uid=$ouid, ou=People, o=aims.edu, o=cp
changetype: modify
delete: pdsRole
pdsRole: generic
-
add: pdsRole
pdsRole: student"  | Out-File -filepath "C:\Users\amoore19\Desktop\LDAP\ui-3rd-party-test1.txt" -append
#sets the output location filename and appends each invidiual output at the bottom of existing output (instead of replacing)
}

Results look like this:

dn: uid=437735121495324, ou=People, o=aims.edu, o=cp
changetype: modify
delete: pdsRole
pdsRole: generic
-
add: pdsRole
pdsRole: student

dn: uid=323099286491410, ou=People, o=aims.edu, o=cp
changetype: modify
delete: pdsRole
pdsRole: generic
-
add: pdsRole
pdsRole: student

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.