项目作者: PowerAruba

项目描述 :
PowerShell module to managed Aruba Central (Cloud)
高级语言: PowerShell
项目地址: git://github.com/PowerAruba/PowerArubaCL.git
创建时间: 2019-12-05T05:49:16Z
项目社区:https://github.com/PowerAruba/PowerArubaCL

开源协议:Apache License 2.0

下载


PowerArubaCL

This is a Powershell module for manage Aruba Central



With this module (version 0.2.0) you can manage:

  • Inventory (Add/Get Devices, Add/Get/Remove Archived Devices, Get Stats)

There is some extra feature

More functionality will be added later.

Tested with Aruba Central ( Region EU-1 )

Usage

All resource management functions are available with the Powershell verbs GET, ADD, SET, REMOVE.
<!—For example, you can manage NAS (NetworkDevice) with the following commands:

  • Get-ArubaCPNetworkDevice
  • Add-ArubaCPNetworkDevice
  • Set-ArubaCPNetworkDevice
  • Remove-ArubaCPNetworkDevice
    —>

    Requirements

  • Powershell 5 or 6.x/7.x (Core) (If possible get the latest version)

  • An Aruba Central Account

Instructions

Install the module

  1. # Automated installation (Powershell 5 and later):
  2. Install-Module PowerArubaCL
  3. # Import the module
  4. Import-Module PowerArubaCL
  5. # Get commands in the module
  6. Get-Command -Module PowerArubaCL
  7. # Get help
  8. Get-Help Add-ArubaCLInventoryDevices -Full

Examples

Connecting to Aruba Central using API

The first thing to do is to get API client_id/client_secret and customer_id

Go on WebGUI of your Aruba Central, on API Gateway (in the Account Home Page)

Go on My Apps & Tokens or System Apps & Tokens (for Admin Account) and click on Add Apps & Tokens


Create a New Token

  • Application: an application name (for example PowerArubaCL)
  • Redirect URI: empty (it is optional)
  • Application: Network Operations

Click on Generate


now copy Client ID and Client Secret, you will need for connect

Go now on the configuration for get the customer id
it is available on the top right

Copy Customer ID value

After connect to Aruba Central with the command Connect-ArubaCL :

  1. # Connect to the Aruba Central using Token
  2. Connect-ArubaCL -region EU-1 -client_id MyClientId -client_secret MyClientSecret -customer_id MyCustomerId
  3. PowerShell credential request
  4. Please enter administrative credential for your Aruba Central
  5. User: cl@poweraruba.net
  6. Password for user cl@poweraruba.net: **********
  7. Name Value
  8. ---- -----
  9. session Microsoft.PowerShell.Commands.WebRequestSession
  10. invokeParams {}
  11. server eu-apigw.central.arubanetworks.com
  12. access_token 565kubYCyDEEaJ4s3zs40yvgtxGTG4Lv
  13. headers {Content-type, Accept, Authorization}

Inventory

You can get Inventory Devices

  1. # get IAP Devices
  2. Get-ArubaCLInventoryDevices -type IAP
  3. aruba_part_no : AP-505-RW
  4. customer_id : 987b69ccdfb03124feeb4a847b9f54d2
  5. customer_name : PowerArubaCL
  6. device_type : iap
  7. imei :
  8. macaddr : B8:3A:5A:1C:22:1C
  9. model : R2H28A
  10. serial : CNJNK0N7PP
  11. services : {}
  12. tier_type :
  13. ...
  14. # Add Devices (need to known Mac Address and Serial Number)
  15. Add-ArubaCLInventoryDevices -mac FC:7F:F2:88:11:22 -serial CNLBAD3C5DT
  16. success
  17. # Get Device Stats
  18. Get-ArubaCLInventoryDevicesStats -type IAP -service dm
  19. licensed total
  20. -------- -----
  21. 44 99
  22. # Get Archived Devices
  23. Get-ArubaCLInventoryDevicesArchive
  24. aruba_part_no : AP-505-RW
  25. customer_id : 987b69ccdfb03124feeb4a847b9f54d2
  26. customer_name : PowerArubaCL
  27. device_type : iap
  28. imei :
  29. macaddr : B8:3A:5A:1C:22:1C
  30. model : R2H28A
  31. serial : CNJNK0N7PP
  32. # Add Devices to Archive (need to known Serial Number)
  33. Add-ArubaCLInventoryDevicesArchive -serial CNJNK0N7PP
  34. success
  35. # Remove Devices to Archive (need to known Serial Number)
  36. Remove-ArubaCLInventoryDevicesArchive -serial CNJNK0N7PP
  37. success

Invoke API

for example to get

  1. # get list of Group
  2. Invoke-ArubaCLRestMethod -uri "configuration/v2/groups?limit=20&offset=0"
  3. data total
  4. ---- -----
  5. {MyPowerArubaCL-Group} 1

to get API uri, go to Aruba Central Swagger (https://eu-apigw.central.arubanetworks.com/swagger/central)
(need to be connected)

MultiConnection

it is possible to connect on same times to Aruba Central account
You need to use -connection parameter to cmdlet

For example to get Devices for 2 different Aruba Central account

  1. # Connect to first Aruba Central Account
  2. $cl1 = Connect-ArubaCL -Region EU-1 -DefaultConnection:$false
  3. #DefaultConnection set to false is not mandatory but only don't set the connection info on global variable
  4. # Connect to second Aruba Central Account
  5. $cl2 = Connect-ArubaCL -Region EU-1 -DefaultConnection:$false
  6. # Get number of Devices of first Aruba Central Account
  7. (Get-ArubaCLInventoryDevices -type IAP -connection $cl1).count
  8. 80
  9. # Get number of Devices of Second Aruba Central Account
  10. (Get-ArubaCLInventoryDevices -type IAP -connection $cl2).count
  11. 90
  12. #Each cmdlet can use -connection parameter

Refresh-Token

By default, the (access) token is valid for 7200 seconds (2 hours), PowerArubaCL store the refreshtoken (valid for 14days ?)
and automatically update (access) token when it is expired (or it will be expire on less of 15 minutes).
If you need to renew token before you can use _Update-ArubaCLRefreshToken
cmdlet

Limit

Following API call, it is possible to have a limit return result.
For Example Get-ArubaCLInventoryDevices return by default only the 50th first devices.
if there is more of 50 devices, you get a warning,

  1. (Get-ArubaCLInventoryDevices -type IAP).count
  2. WARNING: There is extra items use -limit parameter to display
  3. 50

it is possible to specific the limit and the offset

  1. (Get-ArubaCLInventoryDevices -type IAP -limit 1000).count
  2. 365

For Invoke-ArubaCLRestMethod, you can also use limit and offset parameter

Disconnecting

  1. # Disconnect from Aruba Central
  2. Disconnect-ArubaCL

How to contribute

Contribution and feature requests are more than welcome. Please use the following methods:

  • For bugs and issues, please use the issues register with details of the problem.
  • For Feature Requests, please use the issues register with details of what’s required.
  • For code contribution (bug fixes, or feature request), please request fork PowerArubaCL, create a feature/fix branch, add tests if needed then submit a pull request.

Contact

Currently, @alagoutte started this project and will keep maintaining it. Reach out to me via Twitter, Email (see top of file) or the issues Page here on GitHub. If you want to contribute, also get in touch with me.

List of available command

  1. Add-ArubaCLInventoryDevices
  2. Add-ArubaCLInventoryDevicesArchive
  3. Connect-ArubaCL
  4. Disconnect-ArubaCL
  5. Format-ArubaCLMacAddress
  6. Get-ArubaCLInventoryDevices
  7. Get-ArubaCLInventoryDevicesArchive
  8. Get-ArubaCLInventoryDevicesStats
  9. Get-ArubaCLTokenStatus
  10. Invoke-ArubaCLRestMethod
  11. Remove-ArubaCLInventoryDevicesArchive
  12. Set-ArubaCLCipherSSL
  13. Show-ArubaCLException
  14. Update-ArubaCLRefreshToken

Author

Alexis La Goutte

Contributors

  • Cédric Moreau
  • cmcknz77
  • Zak

Sort by name (git shortlog -s)

Special Thanks

License

Copyright 2021 Alexis La Goutte and the community.