Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Connecting to Office365 using PS Function. Can't get cmdlets to work.

$
0
0

I'm trying to use the following function to connect to Office 365 and then run commands outside of the function. If I run the function outside of the function block it works fine, but I keep it in a psm1 and it doesn't allow me to run, for example Get-Mailbox.

Powershell
functionConnect-Exchange365{param()$AESKeyFilePath=**$credentialFilePath=**$passwordSecureString=$Creds.Password$username=**$AESKey=Get-Content$AESKeyFilePath$pwdTxt=Get-Content$credentialFilePath$securePwd=$pwdTxt|ConvertTo-SecureString-Key$AESKey$credObject=New-ObjectSystem.Management.Automation.PSCredential-ArgumentList$username,$securePwd#Opens a Portal the the Exchange Realm$exchangeSession=New-PSSession-ConfigurationNameMicrosoft.Exchange-ConnectionUri**-Credential$credObject-Authentication"Basic"-AllowRedirection...

Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>