1

I am trying to take config backup using Powershell RestMethod.

Commands I tried executing in a terminal and it is working fine but when I am trying using PowerShell I am not able to take the backup

Here for a try, I broke the command into 2. I have even tried below way also

save /sys config ucs /var/local/ucs/backupp.ucs
Function Get-BackupConfig {

    [cmdletBinding()]
    param (
        $F5Session=$Script:F5Session

    )

    #Test that the F5 session is in a valid format
    Test-F5Session($F5Session)

    $URI = $F5Session.BaseURL #-replace "/ltm", "/cm"

    Write-Host $URI
    $JSONBody = @{command='run';utilCmdArgs="save /sys config"}
    $JSONBody = $JSONBody | ConvertTo-Json


    $JSONBody_1 = @{command='run';utilCmdArgs="save /sys ucs 20190503_CR0000"}
    $JSONBody_1 = $JSONBody_1 | ConvertTo-Json

    try
    {
    Invoke-F5RestMethod -Method POST -Uri "$URI" -F5Session $F5Session -Body $JSONBody -ContentType 'application/json' -ErrorMessage "Failed to take backup" -AsBoolean
    Invoke-F5RestMethod -Method POST -Uri "$URI" -F5Session $F5Session -Body $JSONBody_1 -ContentType 'application/json' -ErrorMessage "Failed to take backup" -AsBoolean
    }
    catch
    {
        $exception=$_.ErrorMessage
    }

}

Please let me know I am on the right track or not. The base URL is

https://10.99.XXX.XXX/mgmt/tm/ltm/

and once I execute this, it is returning "False"

Moerwald
  • 10,448
  • 9
  • 43
  • 83
Sandy
  • 81
  • 1
  • 9

0 Answers0