TechTeam2012
asked on
Connecting to O365 connector via PowerShell
Trying to create a quick script for the helpdesk to change calendar permissions on PowerShell through the O365 connector and i was wondering what do i need so that the console doesn't close after the below is run and they can continue with running some commands.
I've seen that running it with the -NoExit switch could work but it's a little cumbersome, is there a better way from within the script?
Help as always is appreciated!
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session
I've seen that running it with the -NoExit switch could work but it's a little cumbersome, is there a better way from within the script?
Help as always is appreciated!
ASKER
I've seen that before and not having much joy with it i'm afraid.
What issues are you having?
You can edit the registry so the default behaviour is to not exit. See this post: http://blog.danskingdom.com/keep-powershell-console-window-open-after-script-finishes-running/
You can edit the registry so the default behaviour is to not exit. See this post: http://blog.danskingdom.com/keep-powershell-console-window-open-after-script-finishes-running/
ASKER
Thanks for getting back to me,
i ideally want a line in the PowerShell that means the helpdesk user's can continue with the commands they're going to use, ie
The problem with launching it from Run with the -NoExit switch is that it always needs to be linked to the same location and i don't want to start editing registrys as it might not always be on the same machine.
Ideally i just need something that runs after
i ideally want a line in the PowerShell that means the helpdesk user's can continue with the commands they're going to use, ie
Get-MailboxFolderPermission -Identity "USER*:\calendar"
The problem with launching it from Run with the -NoExit switch is that it always needs to be linked to the same location and i don't want to start editing registrys as it might not always be on the same machine.
Ideally i just need something that runs after
Import-PSSession $Session
that continues with the prompt, so the helpdesk guys can continue working after the script has run.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Bingo, that's worked perfectly, thanks very much!
Glad to help. :)
https://stackoverflow.com/questions/9362722/stop-powershell-from-exiting