SharePoint Migration - Export IIS Settings

This article is next in the series of articles on “SharePoint Migration & Planning Strategies". You can check out the previous articles in this series using the following link:

In this article, we will look for the PowerShell Scripts to export IIS Settings from the 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 the 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 the 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 Steps 1-6.

3

Once the script is 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

  1. Import - Module WebAdministration  
  2.   
  3. function Get - IIS - Settings() {  
  4.     param($ListName, $ScriptPath, $FileDateTimeStamp)  
  5.     Try {  
  6.         if (Test - Path $settingsFilePath) {  
  7.             Remove - Item $settingsFilePath  
  8.         }  
  9.         $iisSites = Get - Item IIS: \Sites\ * Add - Content $settingsFilePath "Site Name , Site Path , Application Pool , Bindings , Identity , Password"  
  10.         foreach($iisSite in $iisSites) {  
  11.             $appPoolName = $iisSite.ApplicationPool  
  12.             $appPool = get - item "IIS:\AppPools\$appPoolName"  
  13.             $processModel = $appPool.processModel  
  14.             $appPoolIdentity = $processModel.username  
  15.             $appPoolIdentityPassword = $processModel.password  
  16.             $iisBindings = $iisSite.Bindings  
  17.             $iisBindingCollection = $iisBindings.Collection  
  18.             $siteName = $iisSite.Name  
  19.             $sitePath = $iisSite.physicalPath  
  20.             $settings = "$siteName, $sitePath, $appPoolName,$iisBindingCollection,$appPoolIdentity, $appPoolIdentityPassword"  
  21.             Add - content $settingsFilePath $settings  
  22.         }  
  23.     }  
  24.     Catch {  
  25.         Write - Host $Error - ForegroundColor Yellow  
  26.     }  
  27. }  
  28. Clear - Host $settingsFilePath = "C:\Prashant\PowerShell\SharePoint Migration\IISSettings.csv"  
  29. Get - IIS - Settings 

Hope you find it helpful.