Brocade Fibre Channel Networking Community

BNA REST API Connection with PowerShell

  • 1.  BNA REST API Connection with PowerShell

    Posted 03-13-2020 05:35 PM

    I would like to automate to collect Brocade SAN information with BNA REST API.

    We are running BNA 14.4.4. I can use Advance RestClient to connect BNA REST API without any issues. I am trying to use PowerShell Invoke-RestMethod command to script. I can connect with PowerShell command, but I can't find the WStoken. The WStoken is required for subsequent REST API commands.

    Does anyone used PowerShell to connect REST-API? I know there is Python scripts available.

    This is what I have so far...

    PS C:> $headers = @{
    PS C:> $URI=''
    PS C:> $response = Invoke-RestMethod -Uri $URI -Headers $headers -Method Post -SessionVariable bnasession

    PS C:> $response

    serverName serverIp version
    ---------- -------- -------
    AAAAAAAA 14.4.4

    PS C:> $bnasession

    Headers : {[WSpassword, *****], [WSusername, ******], [Content-Type, application/json], [Accept,
    Cookies : System.Net.CookieContainer
    UseDefaultCredentials : False
    Credentials :
    Certificates :
    UserAgent : Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.17763.771
    Proxy :
    MaximumRedirection : -1