Skip to content

Commit

Permalink
Merge pull request #4 from zuehlaa/Issue_when_no_websites_exist
Browse files Browse the repository at this point in the history
Fixes an issue when trying to add a new website when no websites current...
  • Loading branch information
vors committed Apr 25, 2015
2 parents 639cc00 + 570974e commit 12913c4
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions DSCResources/MSFT_xWebsite/MSFT_xWebsite.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function Get-TargetResource
}


# The Set-TargetResource cmdlet is used to create, delete or configuure a website on the target machine.
# The Set-TargetResource cmdlet is used to create, delete or configure a website on the target machine.
function Set-TargetResource
{
[CmdletBinding(SupportsShouldProcess=$true)]
Expand Down Expand Up @@ -267,7 +267,7 @@ function Set-TargetResource

if($UpdateNotRequired)
{
Write-Verbose("Website $Name already exists and properties do not need to be udpated.");
Write-Verbose("Website $Name already exists and properties do not need to be updated.");
}


Expand All @@ -276,7 +276,16 @@ function Set-TargetResource
{
try
{
$Website = New-Website @psboundparameters
$Websites = Get-Website
if ($Websites -eq $null)
{
# We do not have any sites this will cause an exception in 2008R2 if we don't specify an ID
$Website = New-Website @psboundparameters -ID 1
}
else
{
$Website = New-Website @psboundparameters
}
$Result = Stop-Website $Website.name -ErrorAction Stop

#Clear default bindings if new bindings defined and are different
Expand Down Expand Up @@ -433,7 +442,7 @@ function Test-TargetResource
if(ValidateWebsiteBindings -Name $Name -BindingInfo $BindingInfo)
{
$DesiredConfigurationMatch = $false
Write-Verbose("Bindings for website $Name do not mach the desired state.");
Write-Verbose("Bindings for website $Name do not match the desired state.");
break
}

Expand All @@ -452,7 +461,7 @@ function Test-TargetResource
if(-not ($allDefaultPage -icontains $page))
{
$DesiredConfigurationMatch = $false
Write-Verbose("Default Page for website $Name do not mach the desired state.");
Write-Verbose("Default Page for website $Name do not match the desired state.");
$allDefaultPagesPresent = $false
break
}
Expand Down

0 comments on commit 12913c4

Please sign in to comment.