I have a PowerShell script that configures web site and web application settings in IIS. So I use the cmdlets in the WebAdministration snap in. But this script needs to run on
This is great. All I had to do was add an else so it would add the snap-in when run on Windows 2008. This works in scripts for my situation.
Function Load-WebAdmin {
$webAdminModule = get-module -ListAvailable | ? { $_.Name -eq "webadministration" }
If ($webAdminModule -ne $null) {
import-module WebAdministration
}else{
Add-pssnapin WebAdministration
}
}