Remote Session
1 TopicAzure Automation: issues connecting to security and compliance center in remote session
I'm at a loss here. I'm trying to use a Azure Automation PowerShell runbook to connect to the Security and Compliance Center. Specifically I am looking to use theGet-RetentionCompliancePolicy and Set-RetentionCompliancePolicy commands. I've tried a number of different modules to attempt to connect but none seem to work. I have code that works locally, but when put into a runbook and load the same module there, it won't connect properly. Instead it redirects and seems to loop on the connect and import step. When I finally got it to appear to connect and import once (not loop), it does not recognize the Get-RetentionCompliancePolicycommand and I can't find it in a Get-Commands call. Any tips on how to get this to work? below is the code I'm using to connect and import. $cred = Get-AutomationPSCredential -Name "Admin" $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection Import-PSSession $Session -DisableNameChecking -AllowClobber | Out-Null Get-RetentionCompliancePolicy Get-PSSession | Remove-PSSessionSolved2.5KViews0likes1Comment