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

Hope you find it helpful.

<<Previous Part