Hey I have been given a CVS file with the data that I must use to populate some already existing empty users. So far I have been able to populate all the data fields I need such as givenName, description, postalCode etc. However I have been unable to populate the user direct reports field. I am new to PowerShell, please see the code below for any errors.
Import-Csv -Delimiter "," -Path C:\script\PerthUsersa.csv | Foreach {
$ADUser = Get-ADUser -Filter "userPrincipalName -eq '$($_.userPrincipalName)'"
$DirectReport = Get-ADUser
if($ADUser) {
Set-ADUser -Identity $ADUser -givenName $_.givenName -Surname $_.sn -DisplayName $_.displayName -Description $_.description -Office $_.physicalDeliveryOfficeName -EmailAddress $_.mail -StreetAddress $_.streetAddress -City $_.l -State $_.st -PostalCode $_.postalCode -Title $_.title -Department $_.description -MobilePhone $_.mobile -DirectReport $_.directReport
} else {
Write-Warning ("didnt get in " + $($_.userPrincipalName))
}
}
I expected this to also populate the direct report however I have been getting the following error instead:
Set-ADUser : A parameter cannot be found that matches parameter name 'DirectReports'.
At C:\script\perthUsers.ps1:5 char:343
+ ... hone $_.mobile -DirectReports $_.directReports
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser
Thanks in advance.