StevieM Posted January 21, 2016 Posted January 21, 2016 Not sure whether I should post this here or in the Scripts forum. I'm using PowerShell to manage Office 365 mailboxes. When I first connect, I store the credentials in a $cred variable and I am able to run commands. However, if I try to run a command after the connection has been established for longer than 2 minutes, I am prompted to re-enter my password. The same thing happens after the next two minutes. Even when running a long script that imports values from a CSV file, I am prompted for a password mid-flow. I'm sure I never used to have this problem. What am I doing wrong?
Steve21 Posted January 21, 2016 Posted January 21, 2016 Nothing wrong, it's a built in kill switch thingy. Depending on what command you're running and whether o365 returns any values or just does it. There's options to extend it though https://technet.microsoft.com/en-gb/library/hh849703.aspx Steve 1
StevieM Posted January 21, 2016 Author Posted January 21, 2016 (edited) Thanks @Steve21. I've looked at that page already and tried setting the -OperationTimeout to 0 when I first connect, but it still asks for a password when I first run a Set-Mailbox script with an imported CSV and again after two minutes. Edit: In the Powershell command line it says "Creating a new session for implicit remoting of Set-Mailbox command..." whenever it prompts for a password. Edited January 21, 2016 by StevieM
psydii Posted January 21, 2016 Posted January 21, 2016 These links address a slightly different problem, but may be of use: http://blogs.technet.com/b/exchange/archive/2015/11/02/running-powershell-cmdlets-for-large-numbers-of-users-in-office-365.aspx http://blogs.msdn.com/b/ashour/archive/2014/04/30/large-tenant-and-powershell-i-o-timeout.aspx 1
StevieM Posted January 22, 2016 Author Posted January 22, 2016 The problem appears to be that the Set-Mailbox command runs remotely on the Exchange Online server. Although I have created a PSSession and set OperationTimeout options, PowerShell creates another implicit remote session to run the Set-Mailbox command. It is this implicit session that terminates after two minutes, and I appear to have no control over this implicit session. I MUST be doing something wrong, as it seems crazy to give users the ability to automate tasks... provided they sit and wait to enter their credentials every two minutes.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now