SharePoint Migration – Export IIS Settings

This is article is next in the series of articles on “SharePoint Migration & Planning” Strategies. You can reach out to the previous articles in this series using the following links:

SharePoint Migration: Planning & Guidance On SharePoint Objects

In this article we will look for the PowerShell Scripts to export IIS Settings from source SharePoint Farm. This information will be helpful to track all the “Application Pool” accounts used to configure Web Applications in the Farm.

There could be more properties that you can export but for this demo I am considering following important properties:

Site Name, Site Path, Application Pool, Bindings, Identity, Password

In Step 1 we will import module “WebAdministration” which gives us the methods to work with “IIS Manager” Objects

1

In Step 2 we will retrieve items from IIS directory using wildcard path search “IIS:\Sites\*”

In Step 3 we will enlist the header of the output Settings file by using the name of properties that we are pulling from IIS

In Step 4 we will fetch properties “Site Name, Site Path, Application Pool, Bindings, Identity, Password” for each IIS Site

In Step 5 we will append the properties to the output file for each of the IIS sites we have in Farm

2

In Step 6 we are specifying the path for output file which would be in the form of CSV

In Step 7 we are calling the function executing Step 1-6

3

Once the script executed successfully it will generate the output file as shown below-

4

And here is the data that was added to the output file during the execution of the above script

We can see IIS details for each Site (Web Application) added to the SharePoint Farm and this information is really crucial to document during the Migration planning phase.

5

Code Reference:

Import-Module WebAdministration
function Get-IIS-Settings(){    param($ListName,$ScriptPath,$FileDateTimeStamp) Try {        if (Test-Path $settingsFilePath)        {            Remove-Item $settingsFilePath        }
        $iisSites = Get-Item IIS:\Sites\*
        Add-Content $settingsFilePath "Site Name , Site Path , Application Pool , Bindings , Identity , Password"
        foreach ($iisSite in $iisSites)        {            $appPoolName = $iisSite.ApplicationPool            $appPool = get-item "IIS:\AppPools\$appPoolName"            $processModel = $appPool.processModel            $appPoolIdentity = $processModel.username            $appPoolIdentityPassword = $processModel.password            $iisBindings = $iisSite.Bindings            $iisBindingCollection = $iisBindings.Collection             $siteName = $iisSite.Name            $sitePath = $iisSite.physicalPath
            $settings = "$siteName, $sitePath, $appPoolName,$iisBindingCollection,$appPoolIdentity, $appPoolIdentityPassword"             Add-content $settingsFilePath $settings        }
    }    Catch {         Write-Host $Error -ForegroundColor Yellow }}
Clear-Host
$settingsFilePath = "C:\Prashant\PowerShell\SharePoint Migration\IISSettings.csv"
Get-IIS-Settings

Hope you find it helpful.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s