Hi Folks,
I'm struggling with one of our PowerShell scripts. The controller script calls a function which does something in the AAD.
The top of the function looks like this:
function Set-WpAzureMFA { [CmdletBinding()] param ( [Parameter(ParameterSetName = 'Identity', Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $Identity, [Parameter(ParameterSetName = 'Path', Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $Path, [Parameter()] [ValidateNotNullOrEmpty()] [System.Management.Automation.PSCredential] $Credential, [Parameter()] [switch] $Enforced ) begin { try { Write-WpCoreLog 'Importing module MSOnline.' -Script Import-Module -Name 'MSOnline' -ErrorAction Stop Write-WpCoreLog 'Initiating a connection to Azure Active Directory.' -Script Connect-MsolService -Credential $Credential } catch { Write-WpCoreLog -Message 'An unhandled exception was thrown.' -Script -Level 'Error' $PSCmdlet.ThrowTerminatingError($PSItem) } }
The error occurs within the line of
Import-Module -Name 'MSOnline' -ErrorAction Stop
The exception throws:
Import-Module () : Unable to cast object of type 'System.Boolean' to type 'System.Collections.ArrayList'.
Maybe someone has an idea what could be wrong. The script ran fine for months and now it throws these errors.
Thank you in advance!