Hi,
You can look Invoke-ArubaMCRestMethod =>
https://github.com/PowerAruba/PowerArubaMC/blob/master/PowerArubaMC/Private/RestMethod.ps1i add the uidaruba to the uri/url
https://github.com/PowerAruba/PowerArubaMC/blob/master/PowerArubaMC/Private/RestMethod.ps1#L63------------------------------
PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...
PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)
PowerArubaCL: Powershell Module to use Aruba Central
PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..
ACEP / ACMX #107 / ACDX #1281
------------------------------
Original Message:
Sent: Dec 06, 2022 03:43 AM
From: Grzegorz Stolarczyk
Subject: Use Powershell to call ArubaOS 8.7.x.x API no modules allowed
Hi alagoutte!
Thanks for your reply! I've readed your source code, looks very nice :-). Variable $connection has aside other subparams the connection.uidaruba parameter.
The question is how to use it for further calls? I've used it this way, but once again 401, header with $connection.session gives an error...
$GET_API = Invoke-RestMethod -Uri $GetURL -ContentType application/json -Headers $connection -Method Get
Should I add something to your $headers? I've tried this, once again 401:
$headers = @{ Accept = "application/json"; "Content-type" = "application/json"; "Cookie" = $arubamc }
$GET_API = Invoke-RestMethod -Uri $GetURL -ContentType application/json -Headers $headers -Method Get
I've also tried:
$headers = @{ Accept = "application/json"; "Content-type" = "application/json"; "Cookie" = "SESSION= " + $arubamc }
...and also:
$session = $arubamc.Cookies.GetCookies($UriLogon)
$headers = @{ Accept = "application/json"; "Content-type" = "application/json"; "Cookie" = $session }
No luck :-(
Best Regards,
Original Message:
Sent: Dec 05, 2022 03:16 PM
From: Alexis La Goutte
Subject: Use Powershell to call ArubaOS 8.7.x.x API no modules allowed
It is PowerArubaMC for Mobility Controller (and not SW)
You can look the source of connection (and copy/paste the function ^^)
https://github.com/PowerAruba/PowerArubaMC/blob/master/PowerArubaMC/Public/Connection.ps1#L117
i don't remember there is a CSRF for MC API but it will be easy to add (i can look if needed)
------------------------------
PowerArubaSW : Powershell Module to use Aruba Switch API for Vlan, VlanPorts, LACP, LLDP...
PowerArubaCP: Powershell Module to use ClearPass API (create NAD, Guest...)
PowerArubaCL: Powershell Module to use Aruba Central
PowerArubaCX: Powershell Module to use ArubaCX API (get interface/vlan/ports info)..
ACEP / ACMX #107 / ACDX #1281
Original Message:
Sent: Dec 02, 2022 11:01 AM
From: Grzegorz Stolarczyk
Subject: Use Powershell to call ArubaOS 8.7.x.x API no modules allowed
Hello Community!
I'm making first steps to use API on ArubaOS Mobility Master. I've seen some posts for Powershell but none of it suits my requirements.
Due to corporate rightlines I'm unable to install PowerArubaSW module, Python or Postman. Only standard stuff for Microsoft Server 2016...
I'm experiencing problems after this script:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$UriLogon = "https://<MOBILITY_MASTER>:4343/v1/api/login"
$password = "FigureITout"
$Arubabody = "username=<USER>&password=$password"
$Response = Invoke-WebRequest -Uri $UriLogon -Body $Arubabody -Method Post -ContentType application/json -SessionVariable session
$response.StatusCode
$response.StatusDescription
I'm unable to parse the X-CSRF-Token from Invoke-Webrequest, with Invoke-RestMethod I get the Token:
$REST = Invoke-RestMethod -Uri $UriLogon -Body $ArubaBody -Method Post -SessionVariable session -ContentType application/json
$REST._global_result.'X-CSRF-Token'
So far so good... Now I'm trying to get some configuration but the out is "(401) Unauthorized":
$GetURL = "https://<MOBILITY_MASTER>:4343/v1/configuration/object/ssid_prof?config_path=%2Fmd%2F<COMPANY>"
$GET_API = Invoke-RestMethod -Uri $GetURL -Method GET -Headers $Token -ContentType application/json
I think it can have something to do with the cookie which should be provided on each call after logon, but I've found no way to give it to API...
Any suggestions are appreciated!
Best Regards,