IIS - List Sites

Octopus.Script exported 2016-12-19 by BrettJaner belongs to β€˜IIS’ category.

List sites on the server.

Script body

Steps based on this template will execute the following PowerShell script.

try {
	$iisFeature = Get-WindowsFeature Web-WebServer -ErrorAction Stop
	if ($iisFeature -eq $null -or $iisFeature.Installed -eq $false) {
		Write-Error "It looks like IIS is not installed on this server and the deployment is likely to fail."
		Write-Error "Tip: You can use PowerShell to ensure IIS is installed: 'Install-WindowsFeature Web-WebServer'"
		Write-Error "     You are likely to want more IIS features than just the web server. Run 'Get-WindowsFeature *web*' to see all of the features you can install."
		exit 1
	}
} catch {
	Write-Verbose "Call to `Get-WindowsFeature Web-WebServer` failed."
	Write-Verbose "Unable to determine if IIS is installed on this server but will optimistically continue."
}

try {
	Add-PSSnapin WebAdministration -ErrorAction Stop
} catch {
    try {
		 Import-Module WebAdministration -ErrorAction Stop
		} catch {
			Write-Warning "We failed to load the WebAdministration module. This usually resolved by doing one of the following:"
			Write-Warning "1. Install .NET Framework 3.5.1"
			Write-Warning "2. Upgrade to PowerShell 3.0 (or greater)"
			Write-Warning "3. On Windows 2008 you might need to install PowerShell SnapIn for IIS from http://www.iis.net/downloads/microsoft/powershell#additionalDownloads"
			throw ($error | Select-Object -First 1)
    }
}

Get-WebSite

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library β†’ Step templates β†’ Import dialog.

{
  "Id": "05e87da8-a9df-449f-bdbb-98fa44740b46",
  "Name": "IIS - List Sites",
  "Description": "List sites on the server.",
  "Version": 1,
  "ExportedAt": "2016-12-19T23:20:00.000+00:00",
  "ActionType": "Octopus.Script",
  "Author": "BrettJaner",
  "Parameters": [],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "try {\n\t$iisFeature = Get-WindowsFeature Web-WebServer -ErrorAction Stop\n\tif ($iisFeature -eq $null -or $iisFeature.Installed -eq $false) {\n\t\tWrite-Error \"It looks like IIS is not installed on this server and the deployment is likely to fail.\"\n\t\tWrite-Error \"Tip: You can use PowerShell to ensure IIS is installed: 'Install-WindowsFeature Web-WebServer'\"\n\t\tWrite-Error \"     You are likely to want more IIS features than just the web server. Run 'Get-WindowsFeature *web*' to see all of the features you can install.\"\n\t\texit 1\n\t}\n} catch {\n\tWrite-Verbose \"Call to `Get-WindowsFeature Web-WebServer` failed.\"\n\tWrite-Verbose \"Unable to determine if IIS is installed on this server but will optimistically continue.\"\n}\n\ntry {\n\tAdd-PSSnapin WebAdministration -ErrorAction Stop\n} catch {\n    try {\n\t\t Import-Module WebAdministration -ErrorAction Stop\n\t\t} catch {\n\t\t\tWrite-Warning \"We failed to load the WebAdministration module. This usually resolved by doing one of the following:\"\n\t\t\tWrite-Warning \"1. Install .NET Framework 3.5.1\"\n\t\t\tWrite-Warning \"2. Upgrade to PowerShell 3.0 (or greater)\"\n\t\t\tWrite-Warning \"3. On Windows 2008 you might need to install PowerShell SnapIn for IIS from http://www.iis.net/downloads/microsoft/powershell#additionalDownloads\"\n\t\t\tthrow ($error | Select-Object -First 1)\n    }\n}\n\nGet-WebSite",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "IIS",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/iis-list-sites.json",
  "Website": "/step-templates/05e87da8-a9df-449f-bdbb-98fa44740b46",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAF8hJREFUeNrsnXtwW2V6xhVLlmzJtuRL5Mv6lgt2jOMkxJkQtsWBgYbszgBZKPxTAtmZsvyzbZfpTDudMC0dys60MBs67LQDme1mCUxbaLNZoDtJFmaDA+QCXogdx7ET32JHtmTLlmTdIzt9dD5HkY4ulo7OOZKl9xmNR5alcySfn973eb/rmlu3bilIJLFVQP8CEoFFIrBIBBaJRGCRCCwS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4QzCi8EVj6IRjeQJBGNbiBJIhrdQJJENLqBRKKItXpkMplEP2ZVVZVarSaw8lpTU1OiHxO+jcDKd9XW1op+TI1G7i4BAivrVFdXlwOfgsw7iSJWfoiGJpMkEQ1NJkkiGppMkkS5MTSZzDuJwCIRWCQCi0QisEgEFinLVVlZSWDloPR6fWFhYabOjlPjDRBYOSiVSnXfffdlhC2cFKfGG5DuFGtu3bpF1ziDCgQC09PTbrdbtjNqtdqamhpJqSKwSJQKSQQWiURgkQgsEoFFIrBIJAKLRGCRCCwSicAiEVgkAotEIrBIBBaJwCKRCCwSgUUisEgkAotEYJEILBKJwCJlq/5fgAEAh/kq2vedWKoAAAAASUVORK5CYII=",
  "$Meta": {
    "Type": "ActionTemplate"
  }
}

History

Page updated on Monday, December 19, 2016