Forum Discussion

HPosenRU's avatar
HPosenRU
Level 4
4 years ago

NetBackup API call format works in Unix but not Windows

I am running NetBackup 8.2 on a Solaris master. I am writing a script to run on my existing Windows clients for when the server needs to be reinstalled and it needs to have a re-issue token to allow ...
  • HPosenRU's avatar
    HPosenRU
    4 years ago

    So I was finally able to resolve this issue by using the builtin Invoke-WebRequest command. Here is the syntax that I used (Note - auth_header, tokenName and hostId were defined earlier in the script):

    $basepath="https://" + $NBU_master + "/netbackup/"

    $uri = $basepath + "security/securitytokens"

    $reason = "Re-Install"

    $allowedCount = 1

    $validFor = 3600

    $reissue_token = 1

     

    $type = @{

    tokenName=$tokenName

    hostId=$hostId

    reason=$reason

    allowedCount=$allowedCount

    validFor=$validFor

    type=$reissue_token

    }

     

    $response = Invoke-WebRequest `

    -Headers $auth_header `

    -Method POST `

    -Uri $uri `

    -Body (ConvertTo-Json -InputObject $type) `

    -ContentType $content_header_3

     

    $convert = (ConvertFrom-Json -InputObject $response)

    $tokenValue=$convert.tokenValue

     

    Thank you for your help.