In the previous article we have explored the Installation of:
- Windows Azure Platform PowerShell Cmdlets
You can refer the article
For continuing with this article you need to open the PowerShell window and
enter the command: Add-PSSnapin WAPPSCmdlets
Below are the list of Cmdlets and their usage.
- Getting List of Cmdlets
For getting the list of Cmdlet in the loaded package, use Get-Command
E.g.: Get-Command -Module WAPPSCmdlets
- Getting Help
For getting help on a command use Get-Help command followed by the Cmdlet name
E.g.: Get-Help New-Deployment
- Gettting Help with Example
For getting help with example on a particular command use the â€“examples option
E.g.: Get-Help New-Deployment â€“examples
Like -examples, there are options â€“detailed and
â€“full to get detailed and full help on the topic.
Note: You can also get the common commands like:
- exit - To exit the PowerShell application
- cls - To clear the PowerShell screen
- echo - To display text on the screen
Creating PowerShell Scripts
We can create PowerShell Script files. The default extension should be .ps1.
Place the following content inside a file named Command.ps1
Echo "Hello, World!"
Editing PowerShell Scripts
We can edit the PowerShell script file using the Edit option as shown
On clicking the Edit option you can see the following PowerShell Editor.
On executing the script you will get the following error:
"File cannot be loaded because the execution of scripts is
disabled on this system. Please see "get-help about_signing" for more details."
Reason: The system settings restricts running PowerShell scripts.
Solution: Open the PowerShell window in Administrator mode and run the
Note: The Execution Policy supports Unrestricted, Signed and Remotely
Signed scripts. This ensures that an unauthorized script is not executed in the
system. Making policy to Unrestricted is not recommended by for learning
purposes it should be fine.
If you do not run in Administrator mode, you will get the following error:
Set-ExecutionPolicy : Access to the registry key 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft
.PowerShell' is denied.
Reason: The Local Machine registry key is being shared by all users of
system. So Administrative privilege is needed to modify it.
Solution: Run the PowerShell in Administrator mode
After the above problems are resolved, you can see the following output from
Running PowerShell Command Script
In case you need to execute the script manually or through application, you can
use the following command.
powershell.exe â€“noexit c:\temp\command.ps1
The option â€“noexit says to make the execution window remained to view the
results. Run the following command inside the Windows Run window and you can see
the following result.
We can create a windows command script (.cmd) using the above command and later
we executing the same with just a double click.
Invoking a Cmdlet
We are now ready to test a real example of invoking a cmdlet.
Cmdlet: Get-HostedServices piped with Get-HostedProperties
Inputs: SubscriptionId, CertificateThumbprint
The first pane shows the script and the second pane shows the output.
In the script pane the first two lines are variables declaration and value
assign. The Certificate thumbprint can be obtained from Windows Azure Portal.
(Management Certificates > Subscriptions > Select the first child node >
In the above script the output of Get-HostedServices is piped with Get-HostedProperties.
This concludes the usage of Cmdlets. More Cmdlet can be experiment through the
Get-Help option. You can find more examples
In this article we have experimented on:
- Getting Help of Cmdlet
- Getting Help with Examples of Cmdlet
- Creating PowerShell Command Script
- Using PowerShell Script Editor
- Resolving Initial Errors in PowerShell
- Using Cmdlets to get log
I hope this information is enough for going
ahead and automate Azure tasks using the PowerShell Cmdlet and editor.