o365Adm
asked on
Powershell session function or module.
Hi All,
We run powershell scripts through web interface to manage operational activity. Each time we run the below powershell script it loads a new session, downloads all the cmdlets which is taking time. Even for creating a new mailbox we had to wait for the session to be loaded each time.
Out application has provisioned to share runspace and maintain powershell session consitently without creating session.
Could you please help me in creating a powershell session module psm1 file so that we will it while our users access the website for the first time. In the script we will call this module only if session -eq NULL.
We run powershell scripts through web interface to manage operational activity. Each time we run the below powershell script it loads a new session, downloads all the cmdlets which is taking time. Even for creating a new mailbox we had to wait for the session to be loaded each time.
Out application has provisioned to share runspace and maintain powershell session consitently without creating session.
Could you please help me in creating a powershell session module psm1 file so that we will it while our users access the website for the first time. In the script we will call this module only if session -eq NULL.
You are using a PS Host (https://technet.microsoft.com/en-us/library/ee706563(v=vs.85).aspx)? In that, you should have to import the remote session once only, and have full access without redoing any import action.
ASKER
Hi Qlemo,
The requested page cannot be found. May I request to resend the link or article on again.
Thanks.
The requested page cannot be found. May I request to resend the link or article on again.
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you Qlemo.
ASKER
$password = Get-content "C:\temp\password.txt" | convertto-securestring
$credentials = new-object -typename System.Management.Automati
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $Credentials -Authentication Basic -AllowRedirection -warningaction silentlycontinue
$temp = Import-PSSession $Session -allowclobber -warningaction silentlycontinue
Import-Module msonline
Connect-MsolService -Credential $Credentials -warningaction silentlycontinue