Forum Discussion

Steve_Wojo_3284's avatar
Steve_Wojo_3284
Icon for Nimbostratus rankNimbostratus
Nov 07, 2017

Help with iControl cmdlets to check Session status

Hello all,

 

This seems like a fairly easy task, but my scripting skills are unfortunately not up to par. What I am trying to do is have a Powershell script in VSTS that will basically take a pool member out, check that the "Session" is in "user-disabled", then proceed to deploy the site.

 

For some reason this site thinks my post is spam, so I'm trying to post without the code block.

 

1 Reply

  • Looks like I was able to post, so here is the rest of my post:

    Here is the output you get with the get-poolmember cmdlet:

    PS C:\Windows\system32> Get-PoolMember -Address 10.10.10.10
    
    Name                 Partition            Address              Description          Monitor              Session             State              
    ----                 ---------            -------              -----------          -------              -------             -----              
    10.10.10.10:443     Common               10.10.10.10                                default              monitor-enabled     up                 
    

    Here is what I currently have for the script:

    $VerbosePreference = 'Continue'
    
    [Int]$MaxRetries = 20
    
    $RetryCount = 0; $Completed = $false
    
    while (-not $Completed) {
        if ($Node.Session -ne 'monitor-enabled') {
            Write-Verbose "The pool member is disabled"
            $Completed = $true
        }
        else {
            if ($RetryCount -ge $MaxRetries) {
                Write-Verbose "Failed to disable pool member within '$MaxRetries' retries"
                throw "Failed to disable pool member within '$MaxRetries' retries"
            } else {
                Write-Verbose "site still online, retrying in 5 seconds."
                Start-Sleep '5'
                $RetryCount++
            }
        }
    }
    

    Any assistance would be greatly appreciated. Thanks!

    -Steve