Hi; I have downloaded the Granfeldt PowerShell MA and was trying to modify Mr Granfeldt's Office 365 scripts to set licensing on users that have been provisioned into a test tenant. The import script works fine but I am having some issues with the export. It would seem that the line that collects the IsLicensed Boolean value from the connector space is not working and I will be honest, my skills in powershell as it integrates with FIM are not the best...
What I am finding is that when I run the script, the bolded line always returns false (even though the value in the CS is True):
$User = $_.'[DN]'
$User | Out-File -Append $File
$Action = $_.'[ObjectModificationType]'
$Action | Out-File -Append $File
[bool] $IsLicensed = $_.AttributeChanges | where {$_.Name -eq "IsLicensed"} | foreach { [bool] $_.ValueChanges[0].Value }
$AlreadyLicensed = [bool] (Get-MsolUser -userprincipalname $user -ErrorAction SilentlyContinue | Select -Expand isLicensed)
"Should License: $IsLicensed" | Out-File -Append $File
"Is Licensed: $AlreadyLicensed" | Out-File -Append $File
I am assuming that it is just a configuration error on the line and was hoping someone could point out my error. Running the script in the PS ISE returns a conversion error:
Cannot convert value "System.Management.Automation.PSCustomObject" to type "System.Boolean". Boolean parameters accept only Boolean values
and numbers, such as $True, $False, 1 or 0.
Many thanks...