Test if IIS6 installed and .NET 2.0 Registered?

Easier question first: is IIS installed?

$reg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $myComputer);
$subKey= "SYSTEM\CurrentControlSet\Services\W3SVC" -replace '\\', '\\';
if (!($reg.OpenSubKey($subkey))) {
Write-Warning ("${myComputer}: IIS not installed");
$pass = $false;
}

Not as easy a question: is .NET 2.0.50727.0 registered as the ASP.NET handler for IIS?

$subKey= "SOFTWARE\Microsoft\ASP.NET\2.0.50727.0" -replace '\\', '\\';
if (!($reg.OpenSubKey($subkey))) {
Write-Warning ("${myComputer}: .NET 2.0 is not registed with IIS");
$pass = $false;
}

To fix this, run

aspnet_regiis.exe -i

.NET 2.0's aspnet_regiis.exe is found in the %windir%\Microsoft.NET\Framework\v2.0.50727