Need some help with an O365 script

Afternoon all, I’ve started a gig handling O365 where I work, and have what I believe is a simple script that takes my credentials, pipes them into a variable and then proceeds to connect to some O365 Services

$adminName = "" $Password = Get-Content "C:usersmynameDesktopcredentials.txt" | ConvertTo-SecureString $Credential = new-object -typename -Argumentlist $adminname,$Password Import-Module MSOnline Connect-MsolService -Credential $Credential $ExchangeSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $Credential -Authentication Basic -AllowRedirection Import-PSSession $ExchangeSession -AllowClobber Import-Module SkypeOnlineConnector $sfboSession = New-CsOnlineSession -Credential $Credential Import-PSSession $sfboSession Import-Module Microsoft.Online.SharePoint.PowerShell Connect-SPOService -Url "" -Credential $Credential 

However, when it gets to connect-msolservice I get an error below about the sequence containing no elements

Connect-MsolService : Sequence contains no elements At line:1 char:1 + Connect-MsolService -Credential $Credential + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (:) [Connect-MsolService], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.Online.Administration.Automation.ConnectMsolService

Any idea, where I’m going wrong, please? I am still pretty new to it all, but I’m a bit baffled as to why it won’t run! Running it as admin, of course.


submitted by /u/_rickjames
[link] [comments]

Leave a Reply