Jump to content


Powershell REST API Connection

powershell rest api authentication

  • Please log in to reply
3 replies to this topic

#1 SysAdminII

  • Members
  • 1 posts

Posted 02 June 2017 - 04:36 PM

For any one else attempting to connect to their Barracuda Load Balancer ADC using Powershell here is an example script I created. I hope someone else finds it useful

$user = "<username>"
$pass = "<password>"
$uri = "http://<your load balancer>:8000/restapi/v2"
$authbody = @{
	username = $user
	password = $pass
} | ConvertTo-Json

#Login to Barracuda Load Balancer
$auth = Invoke-RestMethod -Method Post -Uri "$uri/login" -ContentType "application/json" -Body $authbody
#Get just the authentication token from the output
$authtoken = $auth.token

#Manually build curl -u equivalent
#Barracuda expects the equivalent of "curl -u token:<blank password>"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(($authtoken + ":")))
$header = @{Authorization = ("Basic " + $base64AuthInfo)}
$stuff = Invoke-RestMethod -Method GET -Uri "$uri/virtual_service_groups" -ContentType "application/json" -Headers $header

#2 rootroot

  • Members
  • 7 posts

Posted 21 June 2017 - 09:26 AM

Can help you if you need, i've written some scripts using the API for certificate imports and bindings... and it's sometimes a pita... especially documentation ;)

#3 Hugo van der Kooij

Hugo van der Kooij
  • Members
  • 3 posts

Posted 13 April 2018 - 06:03 AM

I like where you are going here. To bad I am stuck on a Windows 2008 server which failed on some of these commands.

I guess I can see if I can force an update.


  • Members
  • 5 posts

Posted 20 September 2019 - 11:57 AM

How do I use "Invoke-RestMethod -Method PUT"


I have multiple port using the same IP and when I run this script it sets all Services with that IP to 'Out of Service All'


I need a way to just set the Services I want to 'Out of Service All' or 'In Service'