I am trying to automate some of my o365 scripts so that the helpdesk can run them with elevated permissions and not have that access directly in o365. How do I create a powershell session, automatically passing the 'Run As' Adaxes service account that the custom command is using?
This is what I have so far, but it errors out.
In the powershell script editor it gives me an error 'Cannot process argument transformation on parameter 'Credential'. A command that prompts the user failed because the host program or the command type does not support user interaction.
If I add this custom powershell command to my admin web portal, it errors with:
[ClientAccessServer=MWHPR03CA0014,BackEndServer=,RequestId=9f048b98-c830-4bef-832f-b24b0bf672f5,TimeStamp=11/23/2018 5:20:55 PM] [FailureCategory=LiveID-InvalidCreds]
#Connect to Office 365/MSOL
$o365Credentials = $Context.GetOffice365Credential()
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $o365Credentials -Authentication Basic -AllowRedirection
Import-PSSession $session -AllowClobber -DisableNameChecking