PowerShell commands to authenticate and check licenses in Office 365

Please find the attached build and command script
MSOnline.zip (2.0 KB)

Objective is to pass credentials (username/password) as parameters. Connect/Authenticate with Microsoft Office 365 and check licenses for particular user.

Getting error by passing credentials from orchestrator

@FrankSchikora @huston8 : Share your inputs on this.

@Dawodm : i am getting same error : the connect-msolservice command was found in the module MSOnline, but the module could not be loaded.

In reality module is already installed but still getting this error while executing command “connect-msolservice -credential $cred”.

Not sure whether this is something to do with type argument.

@Ajju : could you share your inputs on this after your review.

@lukas.macas : how you are passing your credentials in invoke powershell activity?

are you sure you’re asking me in correct thread?

@lukas.macas : I am actually running Powershell commands to connect with MsolService but getting errors.
Have you used passed credentials in invoke powershell activity?

I’m using one PS for Set-Acl and… picture say it instead of me :slight_smile:

@lukas.macas : I am actually getting error : Connect-MsolService command was found in MSOnline but module could not be loaded. I am passing credentials as per your screenshot.

param([String]$un,
[String]$pwd
)

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

$cred = new-object -typename System.Management.Automation.PSCredential($un,(ConvertTo-SecureString $pwd -AsPlainText -Force))

Install-Module -Name MSOnline -Scope CurrentUser

Install-Module -Name AzureAD

connect-msolService -credential $cred

Get-MsolAccountSku

I have no experiences with Azure because we’re using MS AD on own premises

@lukas.macas : No worries.

Could you provide your inputs (as per your shared screenshot).

I have similar scenarios to throw exception : No output and error message in PSOutput after commands execution by bot.

In your screenshot, if condition is actually handling no output scenario. How can I check specific text scenario for my case? PSOutput for my case is in System.Collections.ObjectModel.Collection<system.object>

I have TypeArgument set to String so my Output variable is Collection type and after that I’m checking if PSOutput.Count > 0
In your PS script you need to use Return statement.