I'm trying to do something that I don't think should be too complicated of a fix. My end goal: I have certain users in one AD OU that need to use a certain license in Office 365, and different users in a different OU that get a different license.
The command that I'd like to run is:
Get-ADUser -Filter * -SearchBase "ou=test,dc=our,dc=domain,dc=edu" | Set-MsolUserLicense -AddLicenses ourorg:STANDARDWOFFPACK_IW_STUDENT
but that fails with a response of:
Set-MsolUserLicense : The input object cannot be bound because it did not contain the information required to bind all mandatory parameters: ObjectId At line:1 char:111 + Get-ADUser -Filter * -SearchBase "ou=Test students,ou=Students,dc=campus,dc=org,dc=edu" | Set-MsolUserLicense <<<< -AddLicenses nwcu:STANDARDWOFFPACK_IW_STUDENT
Individually, both of these commands work. I can select all users in the OU, and I can also manually use the Set-MsolUserLicense command with -UserPrincipalName to license a single user.
Is this because Get-ADUser doesn't return ObjectID like Set-MsolUserLicense is looking for? Get-ADUser does return ObjectGUID. If I'm on the right track here, is there a way to map these together for the piped input?
Edit: I'm aware the popular ways of doing this involve uploading a CSV file for this, and I know I could CSV-Export these users, but I already have them so neat and tidy in OUs, so I'd love to do this with now import/export if possible.
Thanks in advance!