Forum Discussion

Daniel_S__18443's avatar
Icon for Nimbostratus rankNimbostratus
Jul 21, 2017

Working powershell script sample for (remote disable nodes/pools)?

Hello everyone, I am trying to find a working powershell script sample on how to remotely disable nodes and pools. If anyone can point me at the right direction that will be awesome!


Build: BIG-IP 12.1.1 Build 2.0.204 Hotfix HF2


Thanks, Daniel


2 Replies

  • Joel Newton has written a powershell module:

    Or, if you want to do it with Pure rest I've got a guide here on how to authenticate against the F5 using Powershell:

    Working script to disable a member and node:

    $User = "admin"
    $Password = "admin"
    $f5 = "yourf5.domain.local"
    Create the string that is converted to Base64
    $pair = $user + ":" + $Password
    Encode the string to base64
    $encodedCreds = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($pair))
    Add the "Basic prefix"
    $basicAuthValue = "Basic $encodedCreds"
    Prepare the headers
    $headers = @{
        "Authorization" = $basicAuthValue
        "Content-Type" = "application/json"
    Create the body of the post
    $body = @{"username" = $User; "password" = $Password; "loginProviderName" = "tmos" }
    Convert the body to Json
    $body = $Body | ConvertTo-Json
    $response  = Invoke-WebRequest -Method "POST" -Headers $headers -Body $body -Uri "https://$f5/mgmt/shared/authn/login" 
    Extract the token from the response
    $token = ($response.content | ConvertFrom-Json).Token.token
    Prepare a dictionary with the token
    $headers = @{
        "X-F5-Auth-Token" = $token;
        "content-type" = "application/json";
    Create the body of the post
    $body = @{"state" = "user-down"; "session" = "user-disabled"; }
    Convert the body to Json
    $body = $Body | ConvertTo-Json
    Disable member
    $response  = Invoke-WebRequest -Method "PUT" -Headers $headers -Body $body -Uri "https://$f5/mgmt/tm/ltm/pool/jira.domain.local-8080_pool/members/~Common~server.domain.local:8080/"
    Disable node
    $response  = Invoke-WebRequest -Method "PUT" -Headers $headers -Body $body -Uri "https://$f5/mgmt/tm/ltm/node/~Common~server.domain.local/"


    • Phoenix14467's avatar
      Icon for Nimbostratus rankNimbostratus

      It should be noted that if the PUT request isn't properly crafted that that command can blank out metadata in your nodes in the F5. For example, if you only have state and session in your PUT request, your friendly name will be changed to the IP address and the display name will be cleared.