Wednesday, April 2, 2014

Azure CmdLets which do not support ErrorAction WarningAction behaviour

While working on some scripts for an upcoming presentation I noticed some behavioral changes in the Azure CmdLets particularly with the use of the ErrorAction and WarningAction common parameters.  In my case I was using the Add-DomainControllerAndMemberServer.ps1 (available here) and found that it uses the -ErrorAction parameter for error handling when testing if azure services are already provisioned.

What i found is that the Get-AzureVNetSize cmdlet still throws an error when the Virtual Network does not exist even if you supply the ErrorAction parameter.

So running this:
Get-AzureVNetSite -VNetName "mlaveryvnet"

Or this:
Get-AzureVNetSite -VNetName "mlaveryvnet" -ErrorAction SilentlyContinue

Still results in the following error when the virtual network does not exist:

Get-AzureVNetSite : The specified virtual network name was not found: mlaveryvnet
Parameter name: VirtualNetworkName
At line:1 char:9
+ $vNet = Get-AzureVNetSite -VNetName "mlaveryvnet"
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AzureVNetSite], ArgumentException
    + FullyQualifiedErrorId : System.ArgumentException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVNetSiteCommand

Something to be aware of because even though the cmdlet may take the parameters from the command line, it doesn't mean it has been programed to include that functionality.

In my case I had to switch to the Get-AzureVNetConnection cmdlet as it does provide the functionality and as all I was doing was testing if the network exists this works. Your particular case may differ.

Get-AzureVNetConnection -VNetName "mlaveryvnet" -ErrorAction SilentlyContinue


  1. nice information well done your information is helping alot thanks for valuable windows azure training in hyderabad

  2. The replica giuseppe zanotti shoes are of perfect quality and comfortable to giuseppe zanotti shoes They wear this shoe when they travel, not tired.replica giuseppe zanotti woman wedges polos. I recommended this site to my good friends, they are very happy, can buy such cheap giuseppe zanotti shoes

  3. I bought this copy pen from this store, the quality is very good, replica mont blanc pen has been repurchased many times, recommended to friends around, they all praise the quality of the pen, the store service attitude is good.

  4. Created in 1993, Christian Louboutin’s signature red-bottom heels remain the replica louboutin shoes fashion world’s most stylish stilettos. Level up your shoe collection for less with unbeatable Christian Louboutin sales, replica women louboutin evening where you’ll find alluring Louboutin heels and unique Louboutin shoes in your perfect size.