Connect-msolservice issues while using Import-CliXml credentials

DaveK 1,851 Reputation points

Hi, I'm having some trouble figuring out why some automation wont' work. I'm moving a script from one server which is to be decommissioned so just in process of testing everything is setup as needs so installed required PowerShell modules, updating credentials etc.

I'm using Get-Credentials to save out via Export-CliXML and I've tested the credentials using other modules such as AzureAD and ExchangeOnline - both working fine.

When trying to do the same using "Connect-MsolService -Credentials $Creds" it returns the following error:

Connect-MsolService : One or more errors occurred.
At line:1 char:1
+ Connect-MsolService -Credential $cred
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [Connect-MsolService], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,Microsoft.Online.Administration.Automation.ConnectMsolService

If I just run the Connect-msolService command and manually enter the username/password its working fine so I'm sure I'm missing some secret sauce somewhere but I can't quite figure it out. Its on a freshly built Server 2019 box.

Any Suggestions?

note - I'm aware MS is highlighting the MSOnline modules is being depreciated Q1 next year so I know I'll need to re-write for another method (Graph) at some point but I've got a lot on at the moment so would ideally like to save that work for the new year and just get this script working again.

A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,237 questions
{count} votes