Tuesday 13 January 2015

PowerShell for CaaS 1.3 - Multiple connections and Account management

After the holidays break, we are back with more PowerShell for Dimension Data CaaS (Cloud).  More functionality was added to enhance automation across the board.

We now have more than 90 PowerShell cmdlets interacting with Dimension Data REST API. Please check the previous post for more examples.

Reminder: You can download the latest release and source code on GitHub.

1) Support for multiple connections

Now you can connect to multiple accounts on the same script. This will be very useful if you use multiple datacentres. Therefore we added the Name parameter when you create a connection. You just have to change the active connection to switch. 


$connectionDev=New-CaasConnection -Name "AustraliaConnection" -ApiCredentials (Get-Credential -Message "Dev Connection") -Vendor DimensionData -Region Australia_AU

$connectionDev2=New-CaasConnection -Name "APACConnection" -ApiCredentials (Get-Credential -Message "Dev2 Connection") -Vendor DimensionData -Region AsiaPacific_AP

#list deployed servers on the active connection (AustraliaConnection)
Write-Host "Get Deployed Servers from connection AustraliaConnection"
Get-CaasDeployedServer

#set the active connection to APACConnection
Set-CaasActiveConnection -Name "APACConnection"


#list deployed servers on the active connection (APACConnection)
Write-Host "Get Deployed Servers from connection APACConnection"
Get-CaasDeployedServer


#use the connection parameter to force the cmdlet to use the AustraliaConnection
Get-CaasDeployedServer -Connection $connectionDev


#list all connections stored on the PS session
Get-CaasConnection

#Remove the APACConnection from PS Session
Remove-CaasConnection -Name "APACConnection"


2) Manage Accounts
 The primary administrator can create, update and delete accounts from his/her organisation. Using some the cmdlets from the example below.


#create a helper role object to set which roles the new user will be granted
$roles = New-CaasAccountRoles -Network $true -Backup $true -Server $true -Storage $true -CreateImage $true -Reports $true

#create a new sub-administrator account
New-CaasAccount -Username "testaccount_demo" -FullName "Test Account" -FirstName "Test" -LastName "Account" -Password (ConvertTo-SecureString -AsPlainText -String "password123" -Force) -EmailAddress "test_account@dimensiondata.com" -Roles $roles

#change the new account FullName and FirstName
Set-CaasAccount -Username "testaccount_demo" -FullName "TestAccount2" -FirstName "Test2"

#display all accounts
Get-CaasAccounts

#delete the account
Get-CaasAccounts -Username "testaccount_demo" | Remove-CaasAccount

Please let us know if you have any issues or questions using the PowerShell for Caas.





No comments:

Post a Comment