1

I am attempting to install the Windows PowerShell Snap-In for IIS 7.0 on a server running server 2008 with service pack 2 installed, so I can use the WebAdministration snappin.

On Installation I'm faced with an error

Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product.

Neither Get-PSSnapin nor Get-Module -ListAvailable show WebAdministration, but I do have IIsProviderSnapIn listed. Also, The script provided as an answer to IIS Administration using PowerShell 2 and Modules on Windows 2008 R1 returns False.

Is this an old version of WebAdministration ?

Is this listed under Programs and Features as "Microsoft Windows PowerShell provider for IIS 7.0" ? and if so, can I safely uninstall it, and install the PowerShell Snap-in from the original link?

(Or alternatively, can I use IIsProviderSnapIn to get a list for all the currently running sites, as I would do with the Get-Website in WebAdministration module?)

1

Whilst I'm still not sure exactly what the IIsProviderSnapIn snap-in is compared to WebAdministration, I've ended up with a modified version of an answer to https://stackoverflow.com/questions/1924217/powershell-load-webadministration-in-ps1-script-on-both-iis-7-and-iis-7-5
which loads in the WebAdministration snap-in or module if available, otherwise uses the IIsProviderSnapIn.

$iisVersion = Get-ItemProperty "HKLM:\software\microsoft\InetStp"
$useIISProviderSnappin = $False

if ($iisVersion.MajorVersion -eq 7)
{
    if ($iisVersion.MinorVersion -ge 5)
    {
        Import-Module WebAdministration
    }           
    else
    {

        if(Get-PSSnapIn -Registered | Where {$_.Name -eq "WebAdministration"}) 
        {
            if (-not (Get-PSSnapIn | Where {$_.Name -eq "WebAdministration"})) 
            {
                Add-PSSnapIn WebAdministration
            }
        }
        elseif(Get-PSSnapIn -Registered | Where {$_.Name -eq "IIsProviderSnapIn"})
        {
            #older versions of server 2008 don't have the webadministration module!
            if (-not (Get-PSSnapIn | Where {$_.Name -eq "IIsProviderSnapIn"})) 
            {
                Add-PSSnapIn IIsProviderSnapIn
            }

            $useIISProviderSnappin = $True
        }
        else 
        {
            throw "Unable to import any suitable modules... :( "
        }
    }
}

Function Get-IISWebsite()
{
    if($useIISProviderSnappin)
    {
        return dir iis:\sites
    }
    else
    {
        return Get-Website
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.