locked
Combine Multiple Exchange PowerShell commands RRS feed

  • Question

  • Hi All,

    I would like to combine below commands like a script,is there anyone to do for me ?thank you in advance

    Add-DistributionGroupMember -Identity "Marketing Managers" -Member adam@contoso.com
    Remove-DistributionGroupMember -Identity "Marketing Managers" -Member adam@contoso.com
    Get-Mailbox -Identity testuser | Set-Mailbox -HiddenFromAddressListsEnabled $true
    Get-Mailbox -Identity testuser | Set-CASMailbox -MAPIEnabled:$False
    Get-Mailbox -Identity testuser | Set-CASMailbox -OWAEnabled:$False
    Get-Mailbox -Identity testuser | Set-CASMailbox -ActiveSyncEnabled:$False


    Friday, October 12, 2012 6:02 AM

Answers

  • Copy and paste the above snippet into a txt file, rename it "myscript.ps1" and right click to run it.

    Right click > select > 'Run with Powershell'   

    Or am I mis-taking your intent.


    Don't forget to mark your posts as answered so they drop off the unanswered post filter. If I've helped you and you want to show your gratitude, just click that green thingy.

    Friday, October 12, 2012 7:47 AM

All replies

  • Copy and paste the above snippet into a txt file, rename it "myscript.ps1" and right click to run it.

    Right click > select > 'Run with Powershell'   

    Or am I mis-taking your intent.


    Don't forget to mark your posts as answered so they drop off the unanswered post filter. If I've helped you and you want to show your gratitude, just click that green thingy.

    Friday, October 12, 2012 7:47 AM
  • You can follow knuckle's suggestion to create the script, then run your script in Exchange Management shell.

    Scripting with the Exchange Management Shell

    http://technet.microsoft.com/en-us/library/bb123798.aspx

    Thanks,

    Evan


    Evan Liu

    TechNet Community Support

    Monday, October 15, 2012 9:22 AM
    Moderator