Say you are using a CSV file to import changes to AD and get the import file from a non-technical source, say HR. Most likely you don't have the complete DN of the user. What you can do is create a function to return the DN of the user based on some search criteria, then append it to the result which you can pipe to another command to execute.
1: function format-source {Param($file)
2: $a = Import-Csv $file
3: $result = New-Object PSObject
4: foreach ($i in $a)
5: {
6: $dn = find-user $i.Username Select-Object DN
7: $i Add-Member -Name "DN" -Value $dn -MemberType NoteProperty
8: $result = $i
9: }
10:
11: $result
12:
13: }
No comments:
Post a Comment