New way to connect to AzurePack Powershell

I was struggling with the PowerShell API for Azure Pack. I imported the publishsettingsfile as described in this post. In the past when I wanted to get all the VM’s I could simply run:

Get-WAPackSubscription "Mark Scholman" | Select-WAPackSubscription Get-WAPackVM

And that would give me all my VM’s running on the Azure Pack Subscription. But now it gives me “The remote server returned an error: (403) Forbidden.”:

Looks like since the last update of the Azure Powershell there seems to be some changes.

Let’s start to make it work:

You need to know the API URL for your Azure Pack environment and the publishsettings url.

When you run Get-WAPackEnvironment you see the 2 Azure Environments from the public Azure and Azure China. We need to add our environment (WAPack Environment) there.

Let’s start by adding a WAPack Environment:

Now we need to download the publishsettings file from the AzurePack Environment.(if you have any older subscriptions left in your machine i recommend to clean up the certificates (certmgr.msc) and delete the subscription (Remove-WAPackSubscription)):

This command will open up the portal to download the publishsettings file:

Next we run this command to import the settings into our system. Be aware that the -Environment is specified and attached to the environment we just created.:

Now we can select the subscription and use it as normal:

Now Happy automating again J