locked
WHY WHY WHY WHY doesn't this work!!! RRS feed

  • Question

  • All

    So if anyone can explain why

    Import-csv C:\Temp\aliaslist.csv | Foreach {Get-Mailbox -identity $_.Alias | Remove-MailboxPermission -User wsht.local\svc.qmm -AccessRights FullAccess -InheritanceType All

    Any ideas why this isn't working? I'm trying to remove mailbox permissions for a load of alias' but this isn't working.

    I've checked the syntax etc and it's not working still.

    Cheers

    Alex

    • Moved by Bill_Stewart Friday, November 28, 2014 4:51 PM Abandoned
    Tuesday, September 30, 2014 9:20 AM

Answers

  • -Confirm switch and $ConfirmPreference don't work for Exchange RTM, you need to use Exchange SP1 for that to work.

    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    • Proposed as answer by jrv Tuesday, September 30, 2014 11:19 AM
    • Marked as answer by Just Karl Tuesday, May 12, 2015 9:30 PM
    Tuesday, September 30, 2014 11:15 AM

All replies

    • Marked as answer by Alexgreen312 Tuesday, September 30, 2014 9:45 AM
    • Unmarked as answer by Alexgreen312 Tuesday, September 30, 2014 9:59 AM
    Tuesday, September 30, 2014 9:33 AM
  • OK

    So that's cool, I've got it working but it's asking for me to confirm

    Import-csv C:\Temp\aliaslist.csv | Foreach {Get-Mailbox -identity $_.Alias | Remove-MailboxPermission -User wsht.local\svc.qmm -AccessRights FullAccess -InheritanceType All} -confirm:$false

    I don't want to confirm 7000 times, can you have a look at the above script and see why my -confirm:$false isn't working?


    • Edited by Alexgreen312 Tuesday, September 30, 2014 9:59 AM
    Tuesday, September 30, 2014 9:55 AM
  • It would need to be in the script block, it is optional though so the default behaviour should be not to confirm?
    Tuesday, September 30, 2014 10:11 AM
  • The default is yes to do the change but it still requires a keypress :(

    Import-csv C:\Temp\aliaslist.csv | Foreach {Get-Mailbox -identity $_.Alias | Remove-MailboxPermission -User wsht.local\svc.qmm -AccessRights FullAccess -InheritanceType All -confirm:$false}

    I tried the above and that doesn't work either :(

    Tuesday, September 30, 2014 10:18 AM
  • So if you omit the -confirm switch completely it still requires a key press? You may be able to get around it by setting $confirmPreference to "None" 
    Tuesday, September 30, 2014 10:30 AM
  • Yes it does, where would I need to put the $confirmPreference code?

    Thanks

    Alex

    Tuesday, September 30, 2014 10:45 AM
  • This should work, it's worth setting the preference back to high again afterwards though:

    $confirmPreference = "None"; Import-csv C:\Temp\aliaslist.csv | Foreach {Get-Mailbox -identity $_.Alias | Remove-MailboxPermission -User wsht.local\svc.qmm -AccessRights FullAccess -InheritanceType All}
    

    Tuesday, September 30, 2014 10:50 AM
  • Yeah, it's still asking to confirm again.

    Sigh, I hate this.

    Tuesday, September 30, 2014 10:52 AM
  • Hmmm, setting $ConfirmPreference to none should suppress all confirmation requests. If you type $confirmPreference & $global:confirmpreference into the shell what does each return?
    Tuesday, September 30, 2014 11:00 AM
  • -Confirm switch and $ConfirmPreference don't work for Exchange RTM, you need to use Exchange SP1 for that to work.

    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________ Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

    • Proposed as answer by jrv Tuesday, September 30, 2014 11:19 AM
    • Marked as answer by Just Karl Tuesday, May 12, 2015 9:30 PM
    Tuesday, September 30, 2014 11:15 AM
  • The Confirm parameter on this CmdLet is a "switch" and not a Boolean.  It is also not a Confirm as on most CmdLets.  It can only be present or not.

    Any reference to -confirm:$false or anything else will set the requirement to true.  DO not include the switch.

    If it still prompts then this is one of the buggy commands.  You will have to use primitives to accomplish your task.


    ¯\_(ツ)_/¯

    Tuesday, September 30, 2014 11:18 AM
  • Ah, that would explain it! Every day's a school day :)
    Tuesday, September 30, 2014 11:18 AM