Good morning all. I spent a bit of time last night writing my first real PoSH script to update our AD from a csv export from Peoplesoft. A couple things came up. Thought you all might help.
I read the csv into a variable then pipe it though foreach to process each line of the csv. One of the fields is the employeeID which I use to search AD. This snippet shows this:
$PSInfocsv = import-csv $PSInfoFile
$PSinfocsv | foreach {
$EmpInfo = $_
$Empinfo.EmplID
$EmpAD = get-aduser -Filter{employeeId -eq $Empinfo.EmplID }
...
}
The get-aduser fails with the error:
Property: 'EmplID' not found in object of type: 'System.Management.Automation.PSCustomObject'.
If I save the value of $EmpInfo.emplID to a variable and use the variable in the query this seems to work. I'm guessing by doing so I am casting this as a string. Am I close?
\\Greg