Skip to content

Instantly share code, notes, and snippets.

@nedward
Created April 28, 2015 17:19
Show Gist options
  • Save nedward/d181c84cf6d90c16a876 to your computer and use it in GitHub Desktop.
Save nedward/d181c84cf6d90c16a876 to your computer and use it in GitHub Desktop.
powershell_script "new website for #{site_name}" do
code <<-EOH
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
EOH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment