Skip to content

Commit

Permalink
Merge pull request #210 from PowerShell/dev
Browse files Browse the repository at this point in the history
Release of version 1.13.0.0 of xWebAdministration
  • Loading branch information
kwirkykat authored Aug 10, 2016
2 parents bf122da + 6817b6b commit 9184eb6
Show file tree
Hide file tree
Showing 35 changed files with 3,744 additions and 1,136 deletions.
26 changes: 12 additions & 14 deletions DSCResources/Helper.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ data LocalizedData
'@
}

function New-TerminatingError
{
<#
.SYNOPSIS
<#
.SYNOPSIS
Internal function to throw terminating error with specified
errroCategory, errorId and errorMessage
.PARAMETER ErrorId
.PARAMETER ErrorId
Specifies the Id error message.
.PARAMETER ErrorMessage
.PARAMETER ErrorMessage
Specifies full Error Message to be returned.
.PARAMETER ErrorCategory
.PARAMETER ErrorCategory
Specifies Error Category.
#>

#>
function New-TerminatingError
{
[CmdletBinding()]
param
(
Expand All @@ -40,15 +39,14 @@ function New-TerminatingError
throw $errorRecord
}

function Assert-Module
{
<#
<#
.SYNOPSIS
Internal function to assert if the module exists
.PARAMETER ModuleName
Module to test
#>

#>
function Assert-Module
{
[CmdletBinding()]
param
(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ data LocalizedData
function Get-TargetResource
{
<#
.SYNOPSIS
.SYNOPSIS
This will return a hashtable of results
#>

Expand Down Expand Up @@ -46,7 +46,7 @@ function Get-TargetResource
function Set-TargetResource
{
<#
.SYNOPSIS
.SYNOPSIS
This will set the desired state
#>

Expand All @@ -63,17 +63,18 @@ function Set-TargetResource
)

Write-Verbose($($LocalizedData.ChangedMessage) -f $SectionName, $OverrideMode)

Set-WebConfiguration -Location '' `
-Filter "/system.webServer/$SectionName" `
-PSPath 'machine/webroot/apphost' `
-Metadata overrideMode `
-Value $OverrideMode
-Filter "/system.webServer/$SectionName" `
-PSPath 'machine/webroot/apphost' `
-Metadata 'overrideMode' `
-Value $OverrideMode
}

function Test-TargetResource
{
<#
.SYNOPSIS
.SYNOPSIS
This tests the desired state. If the state is not correct it will return $false.
If the state is correct it will return $true
#>
Expand Down Expand Up @@ -105,10 +106,10 @@ function Test-TargetResource
function Get-OverrideMode
{
<#
.NOTES
Check for a single value.
If $oMode is anything but Allow or Deny, we have a problem with our
Get-WebConfiguration call or the ApplicationHost.config file is corrupted.
.NOTES
Check for a single value.
If $oMode is anything but Allow or Deny, we have a problem with our
Get-WebConfiguration call or the ApplicationHost.config file is corrupted.
#>

param
Expand All @@ -118,9 +119,13 @@ function Get-OverrideMode

Assert-Module

[String] $oMode = ((Get-WebConfiguration -Location '' `
-Filter /system.webServer/$Section `
-Metadata).Metadata).effectiveOverrideMode
Write-Verbose -Message 'Getting override mode'

$webConfig = Get-WebConfiguration -Location '' `
-Filter /system.webServer/$Section `
-Metadata

$oMode = $webConfig.Metadata.effectiveOverrideMode

if ($oMode -notmatch "^(Allow|Deny)$")
{
Expand All @@ -133,6 +138,7 @@ function Get-OverrideMode
return $oMode
}


#endregion

Export-ModuleMember -function *-TargetResource
98 changes: 48 additions & 50 deletions DSCResources/MSFT_xIisLogging/MSFT_xIisLogging.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,12 @@ data LocalizedData
'@
}

<#
.SYNOPSIS
This will return a hashtable of results about the given LogPath
#>
function Get-TargetResource
{
<#
.SYNOPSIS
This will return a hashtable of results
#>

[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
Expand All @@ -42,29 +41,27 @@ function Get-TargetResource

Assert-Module

$CurrentLogSettings = Get-WebConfiguration `
$currentLogSettings = Get-WebConfiguration `
-filter '/system.applicationHost/sites/siteDefaults/Logfile'

Write-Verbose -Message ($LocalizedData.VerboseGetTargetResult)

return @{
LogPath = $CurrentLogSettings.directory
LogFlags = [Array]$CurrentLogSettings.LogExtFileFlags
LogPeriod = $CurrentLogSettings.period
LogTruncateSize = $CurrentLogSettings.truncateSize
LoglocalTimeRollover = $CurrentLogSettings.localTimeRollover
LogFormat = $CurrentLogSettings.logFormat
LogPath = $currentLogSettings.directory
LogFlags = [Array]$currentLogSettings.LogExtFileFlags
LogPeriod = $currentLogSettings.period
LogTruncateSize = $currentLogSettings.truncateSize
LoglocalTimeRollover = $currentLogSettings.localTimeRollover
LogFormat = $currentLogSettings.logFormat
}

Write-Verbose -Message ($LocalizedData.VerboseGetTargetResult)

}

<#
.SYNOPSIS
This will set the desired state
#>
function Set-TargetResource
{
<#
.SYNOPSIS
This will set the desired state
#>

[CmdletBinding()]
param
(
Expand All @@ -88,11 +85,11 @@ function Set-TargetResource

Assert-Module

$CurrentLogState = Get-TargetResource -LogPath $LogPath
$currentLogState = Get-TargetResource -LogPath $LogPath

# Update LogFormat if needed
if ($PSBoundParameters.ContainsKey('LogFormat') -and `
($LogFormat -ne $CurrentLogState.LogFormat))
($LogFormat -ne $currentLogState.LogFormat))
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogFormat)
Set-WebConfigurationProperty '/system.applicationHost/sites/siteDefaults/logfile' `
Expand All @@ -101,7 +98,7 @@ function Set-TargetResource
}

# Update LogPath if needed
if ($PSBoundParameters.ContainsKey('LogPath') -and ($LogPath -ne $CurrentLogState.LogPath))
if ($PSBoundParameters.ContainsKey('LogPath') -and ($LogPath -ne $currentLogState.LogPath))
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogPath)
Set-WebConfigurationProperty '/system.applicationHost/sites/siteDefaults/logfile' `
Expand All @@ -124,7 +121,7 @@ function Set-TargetResource

# Update Log Period if needed
if ($PSBoundParameters.ContainsKey('LogPeriod') -and `
($LogPeriod -ne $CurrentLogState.LogPeriod))
($LogPeriod -ne $currentLogState.LogPeriod))
{
if ($PSBoundParameters.ContainsKey('LogTruncateSize'))
{
Expand All @@ -138,7 +135,7 @@ function Set-TargetResource

# Update LogTruncateSize if needed
if ($PSBoundParameters.ContainsKey('LogTruncateSize') -and `
($LogTruncateSize -ne $CurrentLogState.LogTruncateSize))
($LogTruncateSize -ne $currentLogState.LogTruncateSize))
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLogTruncateSize)
Set-WebConfigurationProperty '/system.Applicationhost/Sites/SiteDefaults/logfile' `
Expand All @@ -152,23 +149,22 @@ function Set-TargetResource
# Update LoglocalTimeRollover if needed
if ($PSBoundParameters.ContainsKey('LoglocalTimeRollover') -and `
($LoglocalTimeRollover -ne `
([System.Convert]::ToBoolean($CurrentLogState.LoglocalTimeRollover))))
([System.Convert]::ToBoolean($currentLogState.LoglocalTimeRollover))))
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetUpdateLoglocalTimeRollover)
Set-WebConfigurationProperty '/system.Applicationhost/Sites/SiteDefaults/logfile' `
-Name localTimeRollover `
-Value $LoglocalTimeRollover
}

}

function Test-TargetResource
{
<#
.SYNOPSIS
<#
.SYNOPSIS
This tests the desired state. If the state is not correct it will return $false.
If the state is correct it will return $true
#>
#>
function Test-TargetResource
{
[CmdletBinding()]
[OutputType([System.Boolean])]
param
Expand All @@ -193,7 +189,7 @@ function Test-TargetResource

Assert-Module

$CurrentLogState = Get-TargetResource -LogPath $LogPath
$currentLogState = Get-TargetResource -LogPath $LogPath

# Check LogFormat
if ($PSBoundParameters.ContainsKey('LogFormat'))
Expand All @@ -204,14 +200,16 @@ function Test-TargetResource
{
Write-Verbose -Message ($LocalizedData.WarningIncorrectLogFormat)
}

# Warn if LogFlags are passed in and Desired LogFormat is not W3C
if($PSBoundParameters.ContainsKey('LogFlags') -and `
$CurrentLogState.LogFormat -ne 'W3C')
$currentLogState.LogFormat -ne 'W3C')
{
Write-Verbose -Message ($LocalizedData.WarningIncorrectLogFormat)
}

# Check LogFormat
if ($LogFormat -ne $CurrentLogState.LogFormat)
if ($LogFormat -ne $currentLogState.LogFormat)
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogFormat)
return $false
Expand All @@ -228,15 +226,15 @@ function Test-TargetResource

# Check LogPath
if ($PSBoundParameters.ContainsKey('LogPath') -and `
($LogPath -ne $CurrentLogState.LogPath))
($LogPath -ne $currentLogState.LogPath))
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogPath)
return $false
}

# Check LogPeriod
if ($PSBoundParameters.ContainsKey('LogPeriod') -and `
($LogPeriod -ne $CurrentLogState.LogPeriod))
($LogPeriod -ne $currentLogState.LogPeriod))
{
if ($PSBoundParameters.ContainsKey('LogTruncateSize'))
{
Expand All @@ -249,7 +247,7 @@ function Test-TargetResource

# Check LogTruncateSize
if ($PSBoundParameters.ContainsKey('LogTruncateSize') -and `
($LogTruncateSize -ne $CurrentLogState.LogTruncateSize))
($LogTruncateSize -ne $currentLogState.LogTruncateSize))
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLogTruncateSize)
return $false
Expand All @@ -258,7 +256,7 @@ function Test-TargetResource
# Check LoglocalTimeRollover
if ($PSBoundParameters.ContainsKey('LoglocalTimeRollover') -and `
($LoglocalTimeRollover -ne `
([System.Convert]::ToBoolean($CurrentLogState.LoglocalTimeRollover))))
([System.Convert]::ToBoolean($currentLogState.LoglocalTimeRollover))))
{
Write-Verbose -Message ($LocalizedData.VerboseTestTargetFalseLoglocalTimeRollover)
return $false
Expand All @@ -270,16 +268,16 @@ function Test-TargetResource

#region Helper functions

function Compare-LogFlags
{
<#
.SYNOPSIS
Helper function used to validate that the logflags status.
<#
.SYNOPSIS
Helper function used to validate the logflags status.
Returns False if the loglfags do not match and true if they do
.PARAMETER LogFlags
Specifies flags to check
#>

#>
function Compare-LogFlags
{
[CmdletBinding()]
[OutputType([Boolean])]
param
Expand All @@ -288,15 +286,15 @@ function Compare-LogFlags
[String[]] $LogFlags
)

$CurrentLogFlags = (Get-WebConfigurationProperty `
$currentLogFlags = (Get-WebConfigurationProperty `
-Filter '/system.Applicationhost/Sites/SiteDefaults/logfile' `
-Name LogExtFileFlags) -split ',' | `
Sort-Object

$ProposedLogFlags = $LogFlags -split ',' | Sort-Object
$proposedLogFlags = $LogFlags -split ',' | Sort-Object

if (Compare-Object -ReferenceObject $CurrentLogFlags `
-DifferenceObject $ProposedLogFlags)
if (Compare-Object -ReferenceObject $currentLogFlags `
-DifferenceObject $proposedLogFlags)
{
return $false
}
Expand Down
Loading

0 comments on commit 9184eb6

Please sign in to comment.