Saturday, December 20, 2008

Windows Azure for Powershell

The Azure SDK includes a setenv.cmd batch file for an Azure Command Prompt. But I haven't used the Command Prompt in ages! Powershell or bust! So.. Here's my Azure PowerShell Prompt script. Add it to the end of your profile.ps1 in the %USERPROFILE%\Documents\WindowsPowerShell folder and go make something cloudy!


##############################################################################################
# AzureCmdPrompt.ps1
##############################################################################################

function SetupAzure($installPath, $netPath)
{
$curPath = $env:path;
$binPath = $installPath + "bin";

$env:PATH = $binPath + ";" + $curPath + ";" + $netPath;
$env:ServiceHostingSDKInstallPath = $installPath;

echo "Windows Azure SDK PowerShell";
$host.ui.RawUI.WindowTitle = "Windows Azure SDK Environment"
}

if (!$env:ServiceHostingSDKInstallPath)
{
if (test-path "hklm:\software\microsoft\microsoft sdks\servicehosting\v1.0")
{
$installPath = $(gp "HKLM:\Software\Microsoft\Microsoft SDKs\ServiceHosting\v1.0").InstallPath
$net64Path = "$env:SystemRoot\Microsoft.NET\Framework64\v3.5";
$net32Path = "$env:SystemRoot\Microsoft.NET\Framework\v3.5";

if (test-path $net64Path)
{ SetupAzure $installPath $net64Path }
elseif (test-path $net32Path)
{ SetupAzure $installPath $net32Path }
else
{ echo "Please install the .NET 3.5 Framework."; }
}
else
{ echo "Please install the Windows Azure SDK."; }
}

No comments: