locked
Get the value of PAM into a variable? RRS feed

  • Question

  • Hi
    This is probably something really simple that I've overlooked, but I needed to put the server name of the PrimaryActiveCluster into a variable and then test it.  What I've got is:

    # Get current PrimaryActiveManager (Owner of the cluster)
    $PAM = Get-DatabaseAvailabilityGroup -Status -Identity MailCluster | Select primaryActiveManager
    If($PAM -ne 'Exch02'){
        # Move PrimaryActiveManager (PAM) to Exch02
        $PAM
    }

    Querying $PAM shows:

    PrimaryActiveManager
    --------------------
    Exch01

    How do I get Exch01 into $PAM without the header?

    Cheers
    Tony

    Wednesday, June 1, 2016 2:41 PM

Answers

  • Thanks Bill for putting me on the right lines.

    if ($PAM.primaryActiveManager.Name -ne 'Exch02')

    This worked

    Wednesday, June 1, 2016 3:36 PM

All replies

  • Use


    $PAM = Get-DatabaseAvailabilityGroup -Status -Identity MailCluster | Select-Object -ExpandProperty primaryActiveManager
    

    or


    if ( $PAM -ne $PAM.primaryActiveManager -ne 'Exch02' ) {
    


    -- Bill Stewart [Bill_Stewart]

    Wednesday, June 1, 2016 2:52 PM
  • Thanks Bill for putting me on the right lines.

    if ($PAM.primaryActiveManager.Name -ne 'Exch02')

    This worked

    Wednesday, June 1, 2016 3:36 PM