FN-GM Posted June 30, 2014 Posted June 30, 2014 Hi, In Exchange Online Powershell is there some kind of limt on the number of pipes I can use? For example if I do this get-mailbox | Set-CasMailbox -OwaMailboxPolicy "Student OWA Policy" -ActiveSyncEnabled $false -PopEnabled $false -ImapEnabled $false -MAPIEnabled $false That works fine and the desired is applied. If I do this get-mailbox | Set-Mailbox -AddressBookPolicy " Student Address Book Policy" That also works fine and the desired is applied. But If I run this get-mailbox | Set-CasMailbox -OwaMailboxPolicy "Student OWA Policy" -ActiveSyncEnabled $false -PopEnabled $false -ImapEnabled $false -MAPIEnabled $false | Set-Mailbox -AddressBookPolicy " Student Address Book Policy" I get no errors as if the command has completed but the address book policy ins't applied Why is it ignoring anything after the second pipe please? Thanks
Domino Posted June 30, 2014 Posted June 30, 2014 Because the 'set-casmailbox' command doesn't return an output?
FN-GM Posted June 30, 2014 Author Posted June 30, 2014 What do you mean when you say the output please?
Domino Posted June 30, 2014 Posted June 30, 2014 Well 'get-mailbox' gets all the mailboxes, and passes that to 'set-casmailbox'. the output from 'set-casmailbox' is passed to 'set-mailbox'.
Domino Posted June 30, 2014 Posted June 30, 2014 Run get-mailbox | Set-CasMailbox -OwaMailboxPolicy "Student OWA Policy" -ActiveSyncEnabled $false -PopEnabled $false -ImapEnabled $false -MAPIEnabled $false then get-mailbox | Set-Mailbox -AddressBookPolicy " Student Address Book Policy"
FN-GM Posted June 30, 2014 Author Posted June 30, 2014 Is there anyway to do it in all one command please?
Domino Posted June 30, 2014 Posted June 30, 2014 or add " -PassThru " onto the first command get-mailbox | Set-CasMailbox -OwaMailboxPolicy "Student OWA Policy" -ActiveSyncEnabled $false -PopEnabled $false -ImapEnabled $false -MAPIEnabled $false -PassThru | Set-Mailbox -AddressBookPolicy " Student Address Book Policy" http://windowsitpro.com/powershell/q-there-way-pipe-object-multiple-commands-when-using-powershell 1
FN-GM Posted June 30, 2014 Author Posted June 30, 2014 Just tried -PassThru like you did above and its an invalid parameter
Domino Posted June 30, 2014 Posted June 30, 2014 Well you could script it with a foreach loop to run through one command, then the other? PowerShell Foreach Loop operator | Foreach-object cmdlet
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