다음을 통해 공유


SharePoint Migration: Export IIS Settings with PowerShell

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

Steps

Steps 1: WebAdministration

We will import module “WebAdministration” which gives us the methods to work with “IIS Manager” Objects

https://howtodowithsharepoint.files.wordpress.com/2018/04/1.png?w=800

Step 2: retrieve items from IIS directory

Retrieve items from IIS directory using wildcard path search “IIS:\Sites\”

Step 3: enlist the header of the output

Enlist the header of the output Settings file by using the name of properties that we are pulling from IIS

Step 4: fetch properties

Fetch properties “Site Name, Site Path, Application Pool, Bindings, Identity, Password” for each IIS Site

Step 5: append the properties

Append the properties to the output file for each of the IIS sites we have in Farm

https://howtodowithsharepoint.files.wordpress.com/2018/04/2.png?w=800

Step 6: path for output file

Specifying the path for output file which would be in the form of CSV

Step 7: calling function

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

https://howtodowithsharepoint.files.wordpress.com/2018/04/3.png?w=800

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

https://howtodowithsharepoint.files.wordpress.com/2018/04/4.png?w=800

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.

https://howtodowithsharepoint.files.wordpress.com/2018/04/5.png?w=800

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:\temp\PowerShell\SharePoint Migration\IISSettings.csv"

Get-IIS-Settings