Skip to content

Instantly share code, notes, and snippets.

@yuriyostapenko
Last active July 13, 2018 09:32
Show Gist options
  • Save yuriyostapenko/b06001b9b455d6b8914499c43ea4ca4c to your computer and use it in GitHub Desktop.
Save yuriyostapenko/b06001b9b455d6b8914499c43ea4ca4c to your computer and use it in GitHub Desktop.
Create IIS Website with http/https bindings with xWebsite using Invoke-DscResource
---
- hosts: <tbd>
tasks:
- name: Configure https binding
win_dsc:
resource_name: xWebsite
Name: "ws2"
Ensure: Present
BindingInfo:
- Protocol: http
Port: 81
- Protocol: https
Port: 4431
CertificateStoreName: My
CertificateThumbprint: 99978a65f4b8d974d0a8f4eb451f145da412c39b
# Prerequisite, don't do it every time :)
#Install-Module xWebAdministration
$Params = @{
Module = 'xWebAdministration';
Name = 'xWebsite';
Property = @{
Name = 'ws2';
BindingInfo = [CimInstance[]]@(
New-CimInstance -ClassName 'MSFT_xWebBindingInformation' -ClientOnly -Property @{
Protocol = "http"
Port = 801
};
New-CimInstance -ClassName 'MSFT_xWebBindingInformation' -ClientOnly -Property @{
Protocol = "https"
Port = 4431
CertificateThumbprint = "99978a65f4b8d974d0a8f4eb451f145da412c39b"
CertificateStoreName = "My"
}
)
Ensure = 'Present'
}
Verbose = $true
}
$TestResult = Invoke-DscResource @Params -Method Test
if (-not $testResult.InDesiredState) {
Invoke-DscResource -Method Set @Params
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment