This PowerShell script tries to load the WAPPSCmdlets snap-in, fails silently if the loading of the snap-in fails (if it isn’t installed), advises the user and exits from the script.
if ((Get-PSSnapin | ?{$_.Name -eq "WAPPSCmdlets"}) -eq $null)
{
Add-PSSnapin WAPPSCmdlets -erroraction SilentlyContinue
$SnapIn = GET-PSSnapIn WAPPSCmdlets -erroraction SilentlyContinue
if ($SnapIn -eq $null)
{
Write-Error "To run this script the 'Windows Azure Platform PowerShell Cmdlets' are required."
Write-Error "Please download from 'http://wappowershell.codeplex.com/' and install as a PowerShell Snap-in (not as a Module)."
Exit
}
}
I’m testing for “WAPPSCmdlets” but you could test for any PowerShell Snap-in.
Simples (if you don’t get it).
0 comments:
Post a Comment