Skip to content

Instantly share code, notes, and snippets.

@Atalanta
Created October 3, 2014 10:35
Show Gist options
  • Select an option

  • Save Atalanta/a994574adbd4b8e37677 to your computer and use it in GitHub Desktop.

Select an option

Save Atalanta/a994574adbd4b8e37677 to your computer and use it in GitHub Desktop.
Import-Module WebAdministration
if (-not(test-path IIS:\\Sites\\#{site_name})){
$NewWebsiteParams = @{Name= '#{site_name}';Port= #{site_data["port"]};PhysicalPath= '#{site_dir}';ApplicationPool= '#{site_name}'}
New-Website @NewWebsiteParams
}
elseif ((Get-WebBinding -Name #{site_name}).bindingInformation -ne '*:#{site_data["port"]}:') {
$CurrentBinding = (Get-WebBinding -Name #{site_name}).bindingInformation
$BindingParameters = @{Name= '#{site_name}';Binding= $CurrentBinding;PropertyName= 'Port';Value = #{site_data["port"]} }
Set-WebBinding @BindingParameters
}
Get-Website -Name #{site_name} | Where {$_.state -like 'Stopped'} | Start-Website
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment