Product: PowerShell Universal
Version: 3.7.7
Hi all, hoping for a little guidance. I’ve got a pretty simple use case, and I just cant quite figure it out. Basically I want to use a persistent runspace that maintains an active connection to exchange online.
That way I can can use that runspace with other scripts and api’s to run exchange commands without having the load up time of running Connect-ExchangeOnline each time i want to make a quick mailbox command.
-
If anyone has a better solution, I’m totally open to suggestions
-
Here’s my use case so far.
I created a pretty basic environment, marked it as persistent, added a couple modules, and created a start up script (Script below) hoping that I could connect to exchange when the environment loads.
StartupScript.ps1
try {
Connect-ExchangeOnline -CertificateThumbprint $thumbprint -AppId $appID -Organization $org -ShowBanner:$false -ErrorAction Stop
"Connected"
} catch {
"Error Connecting"
$Error[0]
}
My hope is that I could write a script or endpoint that could just reference that environment with exchange connected
So I made a quick script, set the environment as my persistent environment, ran it and errored out from not recognizing he exchange commands – which makes me think that my persistent environment didn’t import the modules and connect to exchange. Where am I going wrong?