Partager via


PowerShell Snippets Pt. 2

Some more PowerShell snippets.

Is the IIS Running?

 function Check-IISServiceRunning
{
 try
 {
 $iisService = Get-Service W3SVC -ComputerName localhost
 }
 catch [ServiceCommandException]
 {
 throw "Check IIS service running FAILED. Please install IIS before continueing." 
 }
}
 If you want to start it you can add:
 Start-Service -InputObject $iisService

Install ASP.NET in the IIS?

 function Install-ASPNETIIS
{
  $aspNetRegIISDirectory = "$env:SystemRootMicrosoft.NETFramework64v2.0.50727"
  Start-Process -FilePath "$aspNetRegIISDirectoryaspnet_regiis" -Wait -ArgumentList "-i"
}