none
Powershell Script to "Disable/Enable" Subscriptions

    Question

  • Hi,

    We are using a single RMS Server with some SMTP & SMS Channels,

    And i would like to create a PowerShell script to disable specific channel and enable another one "Disaster Recovery Site"

    Simply i want the engineer from the DR Site just click on the script without enter the RMS Console, and he can disable the primary one and enable the DR Channel

    Thanks..


    • Edited by Sn0w_MOnkEY Tuesday, September 18, 2012 10:40 PM
    Thursday, September 13, 2012 1:42 PM

Answers

  • Hi

    If you Need to disable a notification this maybe help in SCOM 2012

    Get-SCOMNotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-SCOMNotificationSubscription

    in SCOM 2007 (I haven't tested it but should work)

    Get-NotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-NotificationSubscription

    You could build a script like here for SCOM 2012:

    Param([string]$subscription)

    Import-Module OperationsManager

    Get-SCOMNotificationSubscription | where {$_.displayname -like $subscription} | Disable-SCOMNotificationSubscription

    Write-Host -ForegroundColor yellow "Subscription $subscription is disabled"

    Make sure the SCOM console is installed on the Client where you execute the script and the permissions are set properly.

    Cheers,

    Stefan


    Blog: http://blog.scomfaq.ch

    • Marked as answer by Sn0w_MOnkEY Tuesday, September 18, 2012 10:29 PM
    Tuesday, September 18, 2012 9:27 PM
  • Hi

    There is a different "Thing" you have to do, in SCOM 2007 you Need to load the Powershell Snap-in before you can execute SCOM commandlets. It is like this

    $Server = “scom.domain.com”
    Add-PSSnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”
    Set-Location “OperationsManagerMonitoring::”
    New-ManagementGroupConnection –ConnectionString $Server
    Set-location $Server

    So you Need to replace the "import-module OperationsManager" (SCOM 2012) through the code above which is as I mentioned above for SCOM 2007 R2.

    What do you mean by confirm the send notification? You mean you want some kind of confirmation if a notification has been sent or not?

    Question 3, yes of course depending what do you want to do. E.g. you could name the default 2 subscriptions something like Subscription A and Subscription B and the DR Subscriptions like DR_Subscription A and DR_Subscription B then you could create a script which you submit a paramater like "DR" and in the script this will disable the "regular" subscriptions and enable the "DR_Subscriptions". I would put some kind of prefix for the DR subscriptions so you can easily build a script which will enable all DR_* subscriptions and disable the other not DR_* subscriptions.

    O.k.? Or do you need more help?

    Stefan


    Blog: http://blog.scomfaq.ch

    • Marked as answer by Sn0w_MOnkEY Tuesday, September 18, 2012 11:20 PM
    Tuesday, September 18, 2012 11:06 PM

All replies

  • Hi,

    Regarding notification settings, I just noticed the following related cmdlets:

    Enable-NotificationSubscription

    http://technet.microsoft.com/en-us/library/gg132258

    Disable-NotificationSubscription

    http://technet.microsoft.com/en-us/library/gg132240

    In SCOM 2012, there are some new cmdlets:

    Add-SCOMNotificationChannel

    http://technet.microsoft.com/en-us/library/hh918597

    Remove-SCOMNotificationChannel

    http://technet.microsoft.com/en-us/library/hh920239

    Hope this can give you some hints.

    Thanks.

    Nicholas Li

    TechNet Community Support

    • Marked as answer by Sn0w_MOnkEY Friday, September 14, 2012 10:10 AM
    • Unmarked as answer by Sn0w_MOnkEY Sunday, September 16, 2012 9:59 AM
    Friday, September 14, 2012 6:57 AM
    Moderator
  • Hi,

    Regarding notification settings, I just noticed the following related cmdlets:

    Enable-NotificationSubscription

    http://technet.microsoft.com/en-us/library/gg132258

    Disable-NotificationSubscription

    http://technet.microsoft.com/en-us/library/gg132240

    In SCOM 2012, there are some new cmdlets:

    Add-SCOMNotificationChannel

    http://technet.microsoft.com/en-us/library/hh918597

    Remove-SCOMNotificationChannel

    http://technet.microsoft.com/en-us/library/hh920239

    Hope this can give you some hints.

    Thanks.

    Nicholas Li

    TechNet Community Support

    Hi Nicholas,

    Thank you for your reply, i know how to disable or enable all subscriptions

    But i need to disable specific subscriptions not all and enable other instead

    Appreciate if you please guide me :)

    Sunday, September 16, 2012 10:02 AM
  • Hi

    If you Need to disable a notification this maybe help in SCOM 2012

    Get-SCOMNotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-SCOMNotificationSubscription

    in SCOM 2007 (I haven't tested it but should work)

    Get-NotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-NotificationSubscription

    You could build a script like here for SCOM 2012:

    Param([string]$subscription)

    Import-Module OperationsManager

    Get-SCOMNotificationSubscription | where {$_.displayname -like $subscription} | Disable-SCOMNotificationSubscription

    Write-Host -ForegroundColor yellow "Subscription $subscription is disabled"

    Make sure the SCOM console is installed on the Client where you execute the script and the permissions are set properly.

    Cheers,

    Stefan


    Blog: http://blog.scomfaq.ch

    • Marked as answer by Sn0w_MOnkEY Tuesday, September 18, 2012 10:29 PM
    Tuesday, September 18, 2012 9:27 PM
  • Why do you want to enable/disable separate channels instead entire subscriptions? You can make 2 identical subscriptions one using the DR channel one using the regular channel and then enable/disable the subscriptions. That was my Intention on the post above :).

    Stefan


    Blog: http://blog.scomfaq.ch


    Tuesday, September 18, 2012 9:35 PM
  • Hi

    If you Need to disable a notification this maybe help in SCOM 2012

    Get-SCOMNotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-SCOMNotificationSubscription

    in SCOM 2007 (I haven't tested it but should work)

    Get-NotificationSubscription | where {$_.displayname -like "*TestSubscription*"} | Disable-NotificationSubscription

    You could build a script like here for SCOM 2012:

    Param([string]$subscription)

    Import-Module OperationsManager

    Get-SCOMNotificationSubscription | where {$_.displayname -like $subscription} | Disable-SCOMNotificationSubscription

    Write-Host -ForegroundColor yellow "Subscription $subscription is disabled"

    Make sure the SCOM console is installed on the Client where you execute the script and the permissions are set properly.

    Cheers,

    Stefan


    Blog: http://blog.scomfaq.ch

    Hi Stefan,

    first thank you for your reply, i tried the command and it work i also added -or to add more subscriptions

    get-notificationsubscription | where {($_.DisplayName -Like "SubScriptionName") -or ($_.DisplayName -Like "SubScriptionName")} | Disable-NotificationSubscription

    But unfortunately the script is not working maybe because i'm using Ops 2007

    1. How do i run the SCOM powershell instead of the default powershell .ps1 ?

    2. Do you know a way to confirm the send notifications for alerts to be generated since or after like GUI console ?

    3. can i create script to enable two subscription and disable other two subscription at the same script ?

    Thanks in Advance ;)




    • Edited by Sn0w_MOnkEY Tuesday, September 18, 2012 10:36 PM
    Tuesday, September 18, 2012 10:35 PM
  • Hi

    There is a different "Thing" you have to do, in SCOM 2007 you Need to load the Powershell Snap-in before you can execute SCOM commandlets. It is like this

    $Server = “scom.domain.com”
    Add-PSSnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”
    Set-Location “OperationsManagerMonitoring::”
    New-ManagementGroupConnection –ConnectionString $Server
    Set-location $Server

    So you Need to replace the "import-module OperationsManager" (SCOM 2012) through the code above which is as I mentioned above for SCOM 2007 R2.

    What do you mean by confirm the send notification? You mean you want some kind of confirmation if a notification has been sent or not?

    Question 3, yes of course depending what do you want to do. E.g. you could name the default 2 subscriptions something like Subscription A and Subscription B and the DR Subscriptions like DR_Subscription A and DR_Subscription B then you could create a script which you submit a paramater like "DR" and in the script this will disable the "regular" subscriptions and enable the "DR_Subscriptions". I would put some kind of prefix for the DR subscriptions so you can easily build a script which will enable all DR_* subscriptions and disable the other not DR_* subscriptions.

    O.k.? Or do you need more help?

    Stefan


    Blog: http://blog.scomfaq.ch

    • Marked as answer by Sn0w_MOnkEY Tuesday, September 18, 2012 11:20 PM
    Tuesday, September 18, 2012 11:06 PM
  • Hi

    There is a different "Thing" you have to do, in SCOM 2007 you Need to load the Powershell Snap-in before you can execute SCOM commandlets. It is like this

    $Server = “scom.domain.com”
    Add-PSSnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”
    Set-Location “OperationsManagerMonitoring::”
    New-ManagementGroupConnection –ConnectionString $Server
    Set-location $Server

    So you Need to replace the "import-module OperationsManager" (SCOM 2012) through the code above which is as I mentioned above for SCOM 2007 R2.

    What do you mean by confirm the send notification? You mean you want some kind of confirmation if a notification has been sent or not?

    Question 3, yes of course depending what do you want to do. E.g. you could name the default 2 subscriptions something like Subscription A and Subscription B and the DR Subscriptions like DR_Subscription A and DR_Subscription B then you could create a script which you submit a paramater like "DR" and in the script this will disable the "regular" subscriptions and enable the "DR_Subscriptions". I would put some kind of prefix for the DR subscriptions so you can easily build a script which will enable all DR_* subscriptions and disable the other not DR_* subscriptions.

    O.k.? Or do you need more help?

    Stefan


    Blog: http://blog.scomfaq.ch

    Script now work thank you, and i mean by send notification "below picture will be more clear"

    is there any command to pick which action should be run after the sub enable ?

    Tuesday, September 18, 2012 11:20 PM