From 471a75c339bd1399168cf5e59f41be1f9c847bbc Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Sun, 30 Sep 2018 14:01:51 -0600 Subject: [PATCH 01/16] Added xWebConfigPropertyLocation to allow access to locked sections of the ApplicationHost.Config --- .../MSFT_xWebConfigPropertyLocation.psm1 | 431 ++++++++++++++++++ ...MSFT_xWebConfigPropertyLocation.schema.mof | 10 + 2 files changed, 441 insertions(+) create mode 100644 DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.psm1 create mode 100644 DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof diff --git a/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.psm1 b/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.psm1 new file mode 100644 index 000000000..e79bad979 --- /dev/null +++ b/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.psm1 @@ -0,0 +1,431 @@ +# Localized messages +data LocalizedData +{ + # culture="en-US" + ConvertFrom-StringData -StringData @' + VerboseTargetCheckingTarget = Checking for the existence of property "{0}" using filter "{1}" located at "{2}". + VerboseTargetPropertyNotFound = Property "{0}" has not been found. + VerboseTargetPropertyFound = Property "{0}" has been found. + VerboseSetTargetEditItem = Ensuring property "{0}" is set. + VerboseSetTargetRemoveItem = Property "{0}" exists, removing property. +'@ +} + +<# +.SYNOPSIS + Gets the current value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. +#> +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + # Retrieve the value of the existing property if present. + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) + + $Get_ItemValue_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + } + $existingValue = Get-ItemValue @Get_ItemValue_param + + $result = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + Ensure = 'Present' + Value = $existingValue + } + + if ( -not($existingValue) ) { + # Property was not found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) + + $result.Ensure = 'Absent' + } + else { + # Property was found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) + } + + return $result +} + +<# +.SYNOPSIS + Sets the value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. + +.PARAMETER Value + Value of the property to update. + +.PARAMETER Ensure + Present or Absent. Defaults to Present. +#> +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName, + + [Parameter()] + [string] + $Value, + + [Parameter()] + [ValidateSet('Present','Absent')] + [string] + $Ensure = 'Present' + ) + if ($Ensure -eq 'Present') { + # Property needs to be updated. + Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) + + $Get_ItemPropertyType_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + } + $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param + + if ($propertyType -match 'Int32|Int64') + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } + else + { $setValue = $Value } + + $Set_WebConfigurationProperty_param = @{ + Filter = $Filter + PSPath = $WebsitePath + Name = $PropertyName + Value = $setValue + Location = $Location + WarningAction = "Stop" + } + Set-WebConfigurationProperty @Set_WebConfigurationProperty_param + } + else { + # Property needs to be removed. + Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) + + $Clear_WebConfiguration_param = @{ + Filter ="$($Filter)/@$($PropertyName)" + PSPath = $WebsitePath + Location = $Location + WarningAction = "Stop" + } + Clear-WebConfiguration @Clear_WebConfiguration_param + } +} + +<# +.SYNOPSIS + Tests the value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. + +.PARAMETER Value + Value of the property to update. + +.PARAMETER Ensure + Present or Absent. Defaults to Present. +#> +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName, + + [Parameter()] + [string] + $Value, + + [Parameter()] + [ValidateSet('Present','Absent')] + [string] + $Ensure = 'Present' + ) + # Retrieve the value of the existing property if present. + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) + + $Get_TargetResource_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + } + $targetResource = Get-TargetResource @Get_TargetResource_param + + if ($Ensure -eq 'Present') { + if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { + # Property was not found or didn't have expected value. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) + + return $false + } + } + else { + if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { + # Property was found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + + return $false + } + } + + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + + return $true +} + +#region Helper Functions + +<# +.SYNOPSIS + Gets the current value of the property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to retrieve. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to retrieve. +#> +function Get-ItemValue +{ + [CmdletBinding()] + [OutputType([System.Object])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter()] + [ValidateNotNullOrEmpty()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + + # Retrieve the value of the specified property if present. + $Get_WebConfigurationProperty_param = @{ + PSPath = $WebsitePath + Filter = $Filter + Name = $PropertyName + Location = $Location + } + $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param + + # Return the value of the property if located. + if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { + return $value.Value + } + return $value +} + +<# +.SYNOPSIS + Gets the current data type of the property. + +.PARAMETER WebsitePath + Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Filter used to locate property to retrieve. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Name of the property to retrieve. +#> +function Get-ItemPropertyType +{ + [CmdletBinding()] + [OutputType([System.String])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + + $Get_WebConfiguration_param = @{ + Filter = $Filter + PsPath = $WebsitePath + Location = $Location + } + $webConfiguration = Get-WebConfiguration @Get_WebConfiguration_param + + $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript {$_.Name -eq $propertyName} + + return $property.ClrType.Name +} + +<# +.SYNOPSIS + Converts the property from string to appropriate data type. + +.PARAMETER PropertyType + Property type to be converted to. + +.PARAMETER InputValue + Value to be converted. +#> +function Convert-PropertyValue +{ + [CmdletBinding()] + [OutputType([System.ValueType])] + param + ( + [Parameter(Mandatory = $true)] + [string] + $PropertyType, + + [Parameter(Mandatory = $true)] + [string] + $InputValue + ) + + switch ($PropertyType ) { + 'Int32' + { [Int32] $value = [convert]::ToInt32($InputValue, 10) } + 'UInt32' + { [UInt32] $value = [convert]::ToUInt32($InputValue, 10) } + 'Int64' + { [Int64] $value = [convert]::ToInt64($InputValue, 10) } + } + + return $value +} + +#endregion + +Export-ModuleMember -Function *-TargetResource diff --git a/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof b/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof new file mode 100644 index 000000000..e0b281ce9 --- /dev/null +++ b/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof @@ -0,0 +1,10 @@ +[ClassVersion("1.0.0.0"), FriendlyName("xWebConfigPropertyLocation")] +class MSFT_xWebConfigPropertyLocation : OMI_BaseResource +{ + [Key, Description("Path to website location (IIS or WebAdministration format).")] String WebsitePath; + [Key, Description("Filter used to locate property to update.")] String Filter; + [Key, Description("Name of the property to update.")] String PropertyName; + [Key, Description("Location is used to update locked sections in the root config.")] String Location; + [Write, Description("Indicates if the property and value should be present or absent. Defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; + [Write, Description("Value of the property to update.")] String Value; +}; From 88e6a0955ac687ac5d13005b5280124544bded4d Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Sun, 30 Sep 2018 14:39:26 -0600 Subject: [PATCH 02/16] Added documentation to README.MD and samples --- .../Sample_xWebConfigPropertyLocation_Add.ps1 | 34 +++++++++++++++++++ ...mple_xWebConfigPropertyLocation_Remove.ps1 | 33 ++++++++++++++++++ README.md | 12 +++++++ 3 files changed, 79 insertions(+) create mode 100644 Examples/Sample_xWebConfigPropertyLocation_Add.ps1 create mode 100644 Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 diff --git a/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 b/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 new file mode 100644 index 000000000..6f0995547 --- /dev/null +++ b/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 @@ -0,0 +1,34 @@ +<# +.SYNOPSIS + Configures the alternateHostName property of the default website + +.DESCRIPTION + This example shows how to use the xWebConfigPropertyLocation DSC resource for setting a configuration property on the default web site. + It will set the value of the system.webServer/serverRuntime alternateHostName attribute to a specified hostname in the ApplicationHost.config file for the default web site. +#> +Configuration Sample_xWebConfigPropertyLocation_Add +{ + param + ( + # Target nodes to apply the configuration. + [Parameter()] + [String[]] + $NodeName = 'localhost' + ) + + # Import the modules that define custom resources + Import-DscResource -ModuleName xWebAdministration + + Node $NodeName + { + xWebConfigPropertyLocation "$($NodeName)/Default Web Site - Specify the alternateHostName attribute of a site. - Add" + { + WebSitePath = "MACHINE/WEBROOT/APPHOST" + Filter = "system.webServer/serverRuntime" + Location = "Default Web Site" + PropertyName = "alternateHostName" + Value = "" + Ensure = "Present" + } + } +} \ No newline at end of file diff --git a/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 b/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 new file mode 100644 index 000000000..1a11a75ce --- /dev/null +++ b/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 @@ -0,0 +1,33 @@ +<# +.SYNOPSIS + Removes the alternateHostName property of the default website + +.DESCRIPTION + This example shows how to use the xWebConfigPropertyLocation DSC resource for removing a configuration property on the default web site. + It will remove the system.webServer/serverRuntime alternateHostName attribute (if specified) for the default web site. +#> +Configuration Sample_xWebConfigPropertyLocation_Remove +{ + param + ( + # Target nodes to apply the configuration. + [Parameter()] + [String[]] + $NodeName = 'localhost' + ) + + # Import the modules that define custom resources + Import-DscResource -ModuleName xWebAdministration + + Node $NodeName + { + xWebConfigPropertyLocation "$($NodeName)/Default Web Site - Remove the alternateHostName attribute (if specified) - Remove" + { + WebSitePath = "MACHINE/WEBROOT/APPHOST" + Filter = "system.webServer/serverRuntime" + Location = "Default Web Site" + PropertyName = "alternateHostName" + Ensure = "Absent" + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index 54c76768d..9770dda57 100644 --- a/README.md +++ b/README.md @@ -264,6 +264,17 @@ Ensures the value of an identified property in the web.config file. * **Value**: Value of the property to update. * **Ensure**: Indicates if the property and value should be present or absent. Defaults to 'Present'. { *Present* | Absent } +### xWebConfigPropertyLocation + +Ensures the value of an identified property in the ApplicationHost.config file under Location section. + +* **WebsitePath**: Path to website location (IIS or WebAdministration format). +* **Filter**: Filter used to locate property to update. +* **PropertyName**: Name of the property to update. +* **Location**: Name of the location to update. +* **Value**: Value of the property to update. +* **Ensure**: Indicates if the property and value should be present or absent. Defaults to 'Present'. { *Present* | Absent } + ### xWebConfigPropertyCollection Ensures the value of an identified property collection item's property in the web.config file. Builds upon the **xWebConfigKeyValue** resource to support all web.config elements that contain collections of child items. @@ -317,6 +328,7 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### Unreleased +* Added new reosurce xWebConfigProperty extening functionality provided by xWebConfigProperty to allow writing of locked sections in ApplicationHost.Config * Update appveyor.yml to use the default template. * Added default template file .gitattributes, and added default settings for Visual Studio Code. From 542ad3e10a74e0b6a6dc4c325aae0b291df32a7f Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Mon, 8 Oct 2018 20:31:40 -0600 Subject: [PATCH 03/16] Updated xWebConfigProperty with location key param --- .../MSFT_xWebConfigProperty.psm1 | 193 +++++--- .../MSFT_xWebConfigProperty.schema.mof | Bin 646 -> 1526 bytes .../MSFT_xWebConfigPropertyLocation.psm1 | 431 ------------------ ...MSFT_xWebConfigPropertyLocation.schema.mof | 10 - .../Sample_xWebConfigPropertyLocation_Add.ps1 | 34 -- ...mple_xWebConfigPropertyLocation_Remove.ps1 | 33 -- Examples/Sample_xWebConfigProperty_Add.ps1 | 1 + Examples/Sample_xWebConfigProperty_Remove.ps1 | 3 +- 8 files changed, 125 insertions(+), 580 deletions(-) delete mode 100644 DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.psm1 delete mode 100644 DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof delete mode 100644 Examples/Sample_xWebConfigPropertyLocation_Add.ps1 delete mode 100644 Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 5ec082c9a..eb6f93c55 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -21,6 +21,9 @@ data LocalizedData .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. #> @@ -40,41 +43,46 @@ function Get-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) # Retrieve the value of the existing property if present. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $existingValue = Get-ItemValue ` - -WebsitePath $WebsitePath ` - -Filter $Filter ` - -PropertyName $PropertyName + $Get_ItemValue_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + Location = $Location + PropertyName = $PropertyName + } + + $existingValue = Get-ItemValue @Get_ItemValue_param $result = @{ WebsitePath = $WebsitePath Filter = $Filter + Location = $Location PropertyName = $PropertyName Ensure = 'Present' Value = $existingValue } - if (-not($existingValue)) - { + if ( -not($existingValue) ) { # Property was not found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) $result.Ensure = 'Absent' } - else - { + else { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) } return $result @@ -90,6 +98,9 @@ function Get-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -114,6 +125,11 @@ function Set-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -128,40 +144,47 @@ function Set-TargetResource [string] $Ensure = 'Present' ) - if ($Ensure -eq 'Present') - { + if ($Ensure -eq 'Present') { # Property needs to be updated. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) + + $Get_ItemPropertyType_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + Location = $Location + PropertyName = $PropertyName + } - $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath -Filter $Filter -PropertyName $PropertyName + $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param - if ($propertyType -match 'Int32|Int64') - { - $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value - } - else - { - $setValue = $Value + if ($propertyType -match 'Int32|Int64') + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } + else + { $setValue = $Value } + + $Set_WebConfigurationProperty_param = @{ + PSPath = $WebsitePath + Filter = $Filter + Location = $Location + Name = $PropertyName + Value = $setValue + WarningAction = "Stop" } - Set-WebConfigurationProperty ` - -Filter $Filter ` - -PSPath $WebsitePath ` - -Name $PropertyName ` - -Value $setValue ` - -WarningAction Stop + Set-WebConfigurationProperty @Set_WebConfigurationProperty_param } - else - { + else { # Property needs to be removed. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) + + $Clear_WebConfiguration_param = @{ + PSPath = $WebsitePath + Filter ="$($Filter)/@$($PropertyName)" + Location = $Location + WarningAction = "Stop" + } - Clear-WebConfiguration ` - -Filter "$($Filter)/@$($PropertyName)" ` - -PSPath $WebsitePath ` - -WarningAction Stop + Clear-WebConfiguration @Clear_WebConfiguration_param } } @@ -175,6 +198,9 @@ function Set-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -200,6 +226,11 @@ function Test-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -215,39 +246,35 @@ function Test-TargetResource $Ensure = 'Present' ) # Retrieve the value of the existing property if present. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $targetResource = Get-TargetResource ` - -WebsitePath $WebsitePath ` - -Filter $Filter ` - -PropertyName $PropertyName + $Get_TargetResource_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + } - if ($Ensure -eq 'Present') - { - if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) - { + $targetResource = Get-TargetResource @Get_TargetResource_param + + if ($Ensure -eq 'Present') { + if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { # Property was not found or didn't have expected value. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) return $false } } - else - { - if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) - { + else { + if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $false } } - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $true } @@ -264,6 +291,9 @@ function Test-TargetResource .PARAMETER Filter Required. Filter used to locate property to retrieve. +.PARAMETER Location + Optional. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to retrieve. #> @@ -283,20 +313,28 @@ function Get-ItemValue [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) + # Retrieve the value of the specified property if present. - $value = Get-WebConfigurationProperty ` - -PSPath $WebsitePath ` - -Filter $Filter ` - -Name $PropertyName + $Get_WebConfigurationProperty_param = @{ + PSPath = $WebsitePath + Filter = $Filter + Name = $PropertyName + Location = $Location + } + + $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param # Return the value of the property if located. - if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) - { + if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { return $value.Value } return $value @@ -307,13 +345,16 @@ function Get-ItemValue Gets the current data type of the property. .PARAMETER WebsitePath - Path to website location (IIS or WebAdministration format). + Required. Path to website location (IIS or WebAdministration format). .PARAMETER Filter - Filter used to locate property to retrieve. + Required. Filter used to locate property to retrieve. +.PARAMETER Location + Optional. Location tag to use for property. + .PARAMETER PropertyName - Name of the property to retrieve. + Required. Name of the property to retrieve. #> function Get-ItemPropertyType { @@ -331,15 +372,25 @@ function Get-ItemPropertyType [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) - $webConfiguration = Get-WebConfiguration -Filter $Filter -PsPath $WebsitePath + $Get_WebConfiguration_param = @{ + Filter = $Filter + PsPath = $WebsitePath + Location = $Location + } + + $webConfiguration = Get-WebConfiguration @Get_WebConfiguration_param - $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript {$_.Name -eq $propertyName} + $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } return $property.ClrType.Name } diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof index d2a7576a90963809a07342935f4390aefbb0b182..4a999ce4450d34460616232a01707f5a60910907 100644 GIT binary patch literal 1526 zcmb_cTT23A6rAUv|M0O-1tIlXPu&D5OEUC9B)luBEACoJ^w+DI^SSP77-F%k?&X|0 zGjq<_ug@ATF+>9qj|w`N@_&F3V;msB3351Io&gSV1cyAM28rS{D`NmFdR-vZl_Tqr_=@pfIchKP zDDz!NJhyP+oDPi`Gv*mFdb*O+wb+q8JEY6r7e^FDDyz3dQdd+vVRp8Isys1J$&tOtx7k;Tz)o-{w&-_3JhAcr=Y zcy-z(@%p_74a;$O;ZzJcRhpiNDzt?|o3ExlQ}=|Z?}l{wJ!#lp`DeKWw=R*C8(V$9 zf$CqH?R}7z%Cc&aR}*e~VBecGHlXGJ=b1VIKFo(SH`+R{&YG+Hc}+bL`HJ7JzNbw7 NbLLZ2&+B8s?;Eg?1uFmm literal 646 zcma)2!Ab)$6uj?OJaXE?QuJz1wOUxDTCB8(A|< -function Get-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Collections.Hashtable])] - param ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $WebsitePath, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Filter, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Location, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $PropertyName - ) - # Retrieve the value of the existing property if present. - Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - - $Get_ItemValue_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - PropertyName = $PropertyName - Location = $Location - } - $existingValue = Get-ItemValue @Get_ItemValue_param - - $result = @{ - WebsitePath = $WebsitePath - Filter = $Filter - PropertyName = $PropertyName - Location = $Location - Ensure = 'Present' - Value = $existingValue - } - - if ( -not($existingValue) ) { - # Property was not found. - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) - - $result.Ensure = 'Absent' - } - else { - # Property was found. - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) - } - - return $result -} - -<# -.SYNOPSIS - Sets the value of the target resource property. - -.PARAMETER WebsitePath - Required. Path to website location (IIS or WebAdministration format). - -.PARAMETER Filter - Required. Filter used to locate property to update. - -.PARAMETER Location - Required. Location tag to use for property. - -.PARAMETER PropertyName - Required. Name of the property to update. - -.PARAMETER Value - Value of the property to update. - -.PARAMETER Ensure - Present or Absent. Defaults to Present. -#> -function Set-TargetResource -{ - [CmdletBinding()] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $WebsitePath, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Filter, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Location, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $PropertyName, - - [Parameter()] - [string] - $Value, - - [Parameter()] - [ValidateSet('Present','Absent')] - [string] - $Ensure = 'Present' - ) - if ($Ensure -eq 'Present') { - # Property needs to be updated. - Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - - $Get_ItemPropertyType_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - PropertyName = $PropertyName - Location = $Location - } - $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param - - if ($propertyType -match 'Int32|Int64') - { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } - else - { $setValue = $Value } - - $Set_WebConfigurationProperty_param = @{ - Filter = $Filter - PSPath = $WebsitePath - Name = $PropertyName - Value = $setValue - Location = $Location - WarningAction = "Stop" - } - Set-WebConfigurationProperty @Set_WebConfigurationProperty_param - } - else { - # Property needs to be removed. - Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) - - $Clear_WebConfiguration_param = @{ - Filter ="$($Filter)/@$($PropertyName)" - PSPath = $WebsitePath - Location = $Location - WarningAction = "Stop" - } - Clear-WebConfiguration @Clear_WebConfiguration_param - } -} - -<# -.SYNOPSIS - Tests the value of the target resource property. - -.PARAMETER WebsitePath - Required. Path to website location (IIS or WebAdministration format). - -.PARAMETER Filter - Required. Filter used to locate property to update. - -.PARAMETER Location - Required. Location tag to use for property. - -.PARAMETER PropertyName - Required. Name of the property to update. - -.PARAMETER Value - Value of the property to update. - -.PARAMETER Ensure - Present or Absent. Defaults to Present. -#> -function Test-TargetResource -{ - [CmdletBinding()] - [OutputType([System.Boolean])] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $WebsitePath, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Filter, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Location, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $PropertyName, - - [Parameter()] - [string] - $Value, - - [Parameter()] - [ValidateSet('Present','Absent')] - [string] - $Ensure = 'Present' - ) - # Retrieve the value of the existing property if present. - Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - - $Get_TargetResource_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - PropertyName = $PropertyName - Location = $Location - } - $targetResource = Get-TargetResource @Get_TargetResource_param - - if ($Ensure -eq 'Present') { - if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { - # Property was not found or didn't have expected value. - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) - - return $false - } - } - else { - if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { - # Property was found. - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) - - return $false - } - } - - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) - - return $true -} - -#region Helper Functions - -<# -.SYNOPSIS - Gets the current value of the property. - -.PARAMETER WebsitePath - Required. Path to website location (IIS or WebAdministration format). - -.PARAMETER Filter - Required. Filter used to locate property to retrieve. - -.PARAMETER Location - Required. Location tag to use for property. - -.PARAMETER PropertyName - Required. Name of the property to retrieve. -#> -function Get-ItemValue -{ - [CmdletBinding()] - [OutputType([System.Object])] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $WebsitePath, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Filter, - - [Parameter()] - [ValidateNotNullOrEmpty()] - [string] - $Location, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $PropertyName - ) - - # Retrieve the value of the specified property if present. - $Get_WebConfigurationProperty_param = @{ - PSPath = $WebsitePath - Filter = $Filter - Name = $PropertyName - Location = $Location - } - $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param - - # Return the value of the property if located. - if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { - return $value.Value - } - return $value -} - -<# -.SYNOPSIS - Gets the current data type of the property. - -.PARAMETER WebsitePath - Path to website location (IIS or WebAdministration format). - -.PARAMETER Filter - Filter used to locate property to retrieve. - -.PARAMETER Location - Required. Location tag to use for property. - -.PARAMETER PropertyName - Name of the property to retrieve. -#> -function Get-ItemPropertyType -{ - [CmdletBinding()] - [OutputType([System.String])] - param - ( - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $WebsitePath, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Filter, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $Location, - - [Parameter(Mandatory = $true)] - [ValidateNotNullOrEmpty()] - [string] - $PropertyName - ) - - $Get_WebConfiguration_param = @{ - Filter = $Filter - PsPath = $WebsitePath - Location = $Location - } - $webConfiguration = Get-WebConfiguration @Get_WebConfiguration_param - - $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript {$_.Name -eq $propertyName} - - return $property.ClrType.Name -} - -<# -.SYNOPSIS - Converts the property from string to appropriate data type. - -.PARAMETER PropertyType - Property type to be converted to. - -.PARAMETER InputValue - Value to be converted. -#> -function Convert-PropertyValue -{ - [CmdletBinding()] - [OutputType([System.ValueType])] - param - ( - [Parameter(Mandatory = $true)] - [string] - $PropertyType, - - [Parameter(Mandatory = $true)] - [string] - $InputValue - ) - - switch ($PropertyType ) { - 'Int32' - { [Int32] $value = [convert]::ToInt32($InputValue, 10) } - 'UInt32' - { [UInt32] $value = [convert]::ToUInt32($InputValue, 10) } - 'Int64' - { [Int64] $value = [convert]::ToInt64($InputValue, 10) } - } - - return $value -} - -#endregion - -Export-ModuleMember -Function *-TargetResource diff --git a/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof b/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof deleted file mode 100644 index e0b281ce9..000000000 --- a/DSCResources/MSFT_xWebConfigPropertyLocation/MSFT_xWebConfigPropertyLocation.schema.mof +++ /dev/null @@ -1,10 +0,0 @@ -[ClassVersion("1.0.0.0"), FriendlyName("xWebConfigPropertyLocation")] -class MSFT_xWebConfigPropertyLocation : OMI_BaseResource -{ - [Key, Description("Path to website location (IIS or WebAdministration format).")] String WebsitePath; - [Key, Description("Filter used to locate property to update.")] String Filter; - [Key, Description("Name of the property to update.")] String PropertyName; - [Key, Description("Location is used to update locked sections in the root config.")] String Location; - [Write, Description("Indicates if the property and value should be present or absent. Defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; - [Write, Description("Value of the property to update.")] String Value; -}; diff --git a/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 b/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 deleted file mode 100644 index 6f0995547..000000000 --- a/Examples/Sample_xWebConfigPropertyLocation_Add.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -<# -.SYNOPSIS - Configures the alternateHostName property of the default website - -.DESCRIPTION - This example shows how to use the xWebConfigPropertyLocation DSC resource for setting a configuration property on the default web site. - It will set the value of the system.webServer/serverRuntime alternateHostName attribute to a specified hostname in the ApplicationHost.config file for the default web site. -#> -Configuration Sample_xWebConfigPropertyLocation_Add -{ - param - ( - # Target nodes to apply the configuration. - [Parameter()] - [String[]] - $NodeName = 'localhost' - ) - - # Import the modules that define custom resources - Import-DscResource -ModuleName xWebAdministration - - Node $NodeName - { - xWebConfigPropertyLocation "$($NodeName)/Default Web Site - Specify the alternateHostName attribute of a site. - Add" - { - WebSitePath = "MACHINE/WEBROOT/APPHOST" - Filter = "system.webServer/serverRuntime" - Location = "Default Web Site" - PropertyName = "alternateHostName" - Value = "" - Ensure = "Present" - } - } -} \ No newline at end of file diff --git a/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 b/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 deleted file mode 100644 index 1a11a75ce..000000000 --- a/Examples/Sample_xWebConfigPropertyLocation_Remove.ps1 +++ /dev/null @@ -1,33 +0,0 @@ -<# -.SYNOPSIS - Removes the alternateHostName property of the default website - -.DESCRIPTION - This example shows how to use the xWebConfigPropertyLocation DSC resource for removing a configuration property on the default web site. - It will remove the system.webServer/serverRuntime alternateHostName attribute (if specified) for the default web site. -#> -Configuration Sample_xWebConfigPropertyLocation_Remove -{ - param - ( - # Target nodes to apply the configuration. - [Parameter()] - [String[]] - $NodeName = 'localhost' - ) - - # Import the modules that define custom resources - Import-DscResource -ModuleName xWebAdministration - - Node $NodeName - { - xWebConfigPropertyLocation "$($NodeName)/Default Web Site - Remove the alternateHostName attribute (if specified) - Remove" - { - WebSitePath = "MACHINE/WEBROOT/APPHOST" - Filter = "system.webServer/serverRuntime" - Location = "Default Web Site" - PropertyName = "alternateHostName" - Ensure = "Absent" - } - } -} \ No newline at end of file diff --git a/Examples/Sample_xWebConfigProperty_Add.ps1 b/Examples/Sample_xWebConfigProperty_Add.ps1 index e8a350583..add41bd35 100644 --- a/Examples/Sample_xWebConfigProperty_Add.ps1 +++ b/Examples/Sample_xWebConfigProperty_Add.ps1 @@ -25,6 +25,7 @@ Configuration Sample_xWebConfigProperty_Add { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' Value = 'false' Ensure = 'Present' diff --git a/Examples/Sample_xWebConfigProperty_Remove.ps1 b/Examples/Sample_xWebConfigProperty_Remove.ps1 index 3f78a9ee7..930f65d4e 100644 --- a/Examples/Sample_xWebConfigProperty_Remove.ps1 +++ b/Examples/Sample_xWebConfigProperty_Remove.ps1 @@ -25,7 +25,8 @@ Configuration Sample_xWebConfigProperty_Remove { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' - PropertyName = 'enabled' + Location = '' + PropertyName = 'enabled' Ensure = 'Absent' } } From e017a46131a8eadafed042eb8d5e00d14718318c Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Mon, 8 Oct 2018 20:36:16 -0600 Subject: [PATCH 04/16] Cleaned up tabs --- .../MSFT_xWebConfigProperty.psm1 | 30 +++++++++---------- Examples/Sample_xWebConfigProperty_Add.ps1 | 2 +- Examples/Sample_xWebConfigProperty_Remove.ps1 | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index eb6f93c55..d43c4b18c 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -22,7 +22,7 @@ data LocalizedData Required. Filter used to locate property to update. .PARAMETER Location - Required. Location tag to use for property. + Required. Location tag to use for property. .PARAMETER PropertyName Required. Name of the property to update. @@ -68,7 +68,7 @@ function Get-TargetResource $result = @{ WebsitePath = $WebsitePath Filter = $Filter - Location = $Location + Location = $Location PropertyName = $PropertyName Ensure = 'Present' Value = $existingValue @@ -99,7 +99,7 @@ function Get-TargetResource Required. Filter used to locate property to update. .PARAMETER Location - Required. Location tag to use for property. + Required. Location tag to use for property. .PARAMETER PropertyName Required. Name of the property to update. @@ -147,20 +147,20 @@ function Set-TargetResource if ($Ensure -eq 'Present') { # Property needs to be updated. Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - - $Get_ItemPropertyType_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter + + $Get_ItemPropertyType_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter Location = $Location - PropertyName = $PropertyName + PropertyName = $PropertyName } $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param if ($propertyType -match 'Int32|Int64') - { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } else - { $setValue = $Value } + { $setValue = $Value } $Set_WebConfigurationProperty_param = @{ PSPath = $WebsitePath @@ -199,7 +199,7 @@ function Set-TargetResource Required. Filter used to locate property to update. .PARAMETER Location - Required. Location tag to use for property. + Required. Location tag to use for property. .PARAMETER PropertyName Required. Name of the property to update. @@ -268,7 +268,7 @@ function Test-TargetResource else { if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { # Property was found. - Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $false } @@ -292,7 +292,7 @@ function Test-TargetResource Required. Filter used to locate property to retrieve. .PARAMETER Location - Optional. Location tag to use for property. + Optional. Location tag to use for property. .PARAMETER PropertyName Required. Name of the property to retrieve. @@ -351,8 +351,8 @@ function Get-ItemValue Required. Filter used to locate property to retrieve. .PARAMETER Location - Optional. Location tag to use for property. - + Optional. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to retrieve. #> diff --git a/Examples/Sample_xWebConfigProperty_Add.ps1 b/Examples/Sample_xWebConfigProperty_Add.ps1 index add41bd35..69717d67e 100644 --- a/Examples/Sample_xWebConfigProperty_Add.ps1 +++ b/Examples/Sample_xWebConfigProperty_Add.ps1 @@ -25,7 +25,7 @@ Configuration Sample_xWebConfigProperty_Add { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' - Location = '' + Location = '' PropertyName = 'enabled' Value = 'false' Ensure = 'Present' diff --git a/Examples/Sample_xWebConfigProperty_Remove.ps1 b/Examples/Sample_xWebConfigProperty_Remove.ps1 index 930f65d4e..f5a4fabf6 100644 --- a/Examples/Sample_xWebConfigProperty_Remove.ps1 +++ b/Examples/Sample_xWebConfigProperty_Remove.ps1 @@ -26,7 +26,7 @@ Configuration Sample_xWebConfigProperty_Remove WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' Location = '' - PropertyName = 'enabled' + PropertyName = 'enabled' Ensure = 'Absent' } } From 2aa7d65db4432533faaa31db88963b3daa3a51c1 Mon Sep 17 00:00:00 2001 From: Geoffrey Guynn Date: Thu, 18 Oct 2018 11:23:07 -0600 Subject: [PATCH 05/16] Updated unit/integration tests --- ...T_xWebConfigProperty.Integration.Tests.ps1 | 1 + .../MSFT_xWebConfigProperty.config.ps1 | 4 + Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 | 206 ++++++++++++++++-- 3 files changed, 197 insertions(+), 14 deletions(-) diff --git a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 index 1cc1e28c3..f1d115da4 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 @@ -47,6 +47,7 @@ try NodeName = 'localhost' WebsitePath = "IIS:\Sites\$($websiteName)" Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' AddValue = $true UpdateValue = $false diff --git a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 index d8b5e2500..8058bd844 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 @@ -8,6 +8,7 @@ Configuration MSFT_xWebConfigProperty_Add { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.AddValue Ensure = 'Present' @@ -25,6 +26,7 @@ Configuration MSFT_xWebConfigProperty_Update { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.UpdateValue Ensure = 'Present' @@ -42,6 +44,7 @@ Configuration MSFT_xWebConfigProperty_Integer { WebsitePath = $Node.WebsitePath Filter = $Node.IntegerFilter + Location = $Node.Location PropertyName = $Node.IntergerPropertyName Value = $Node.IntegerValue Ensure = 'Present' @@ -59,6 +62,7 @@ Configuration MSFT_xWebConfigProperty_Remove { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Ensure = 'Absent' } diff --git a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 index 324968285..e870c88c9 100644 --- a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 +++ b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 @@ -33,27 +33,44 @@ try $script:DSCModuleName = 'xWebAdministration' $script:DSCResourceName = 'MSFT_xWebConfigProperty' - $script:presentParameters = @{ + $script:presentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Value = 'true' Ensure = 'Present' } - - $script:absentParameters = @{ + $script:presentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Value = 'true' + Ensure = 'Present' + } + $script:absentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Ensure = 'Absent' } + $script:absentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Ensure = 'Absent' + } #region Function Get-TargetResource Describe "$($script:DSCResourceName)\Get-TargetResource" { - Context 'Value is absent' { + Context 'Value is absent with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -74,10 +91,36 @@ try } } - Context 'Value is present' { + Context 'Value is absent with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/security/access' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Absent' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be $null + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } + + Context 'Value is present with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -97,6 +140,31 @@ try Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly } } + + Context 'Value is present with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Present' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be 'true' + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } } #endregion Function Get-TargetResource @@ -107,7 +175,19 @@ try return $null } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -119,7 +199,19 @@ try return [System.String]::Empty } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is an empty string at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return [System.String]::Empty + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -131,7 +223,19 @@ try return 'false' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is wrong at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'false' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -143,7 +247,19 @@ try return 'true' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is present and the value is the same at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -155,7 +271,19 @@ try return 'true' } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is absent but value is not null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -167,7 +295,19 @@ try return $null } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is absent and value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -183,7 +323,21 @@ try Mock -CommandName Convert-PropertyValue Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 0 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - String Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'String' } + Mock -CommandName Convert-PropertyValue + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -197,7 +351,21 @@ try Mock -CommandName Convert-PropertyValue -MockWith { return '32' } Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 1 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - Integer Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'Int32' } + Mock -CommandName Convert-PropertyValue -MockWith { return '32' } + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -209,7 +377,17 @@ try Context 'Ensure is absent' { Mock -CommandName Clear-WebConfiguration - Set-TargetResource @script:absentParameters + Set-TargetResource @script:absentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly + } + } + + Context 'Ensure is absent at location' { + Mock -CommandName Clear-WebConfiguration + + Set-TargetResource @script:absentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly From eecb9a8e8bbbc9d340284a79412515a067ea43c7 Mon Sep 17 00:00:00 2001 From: Geoffrey Guynn Date: Thu, 18 Oct 2018 11:59:58 -0600 Subject: [PATCH 06/16] Changed to ASCII --- .../MSFT_xWebConfigProperty.psm1 | Bin 11001 -> 22892 bytes .../MSFT_xWebConfigProperty.schema.mof | Bin 1526 -> 1312 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index d43c4b18c86dd3bc6bce7bc3f388f4d0cd2a02f4..2e30be79d1e4e688fea3f443622c53a6ad7c5196 100644 GIT binary patch literal 22892 zcmeHPZEqvT4W7>h`X7X|0Nce$P12$til#UxxoZySy}-WaP#A{c_j7AYj-+#XP4d^< zKF?4zIkU6cl_R_7!@`hd&(3g24#^=ooc-^A)_#`6jKKf~`aa2cTA41b^F*;&xJdbRCO!g>Pry9nJ)|Q~XZ~kMO&P9;f(y6=}Ib3n}}6mPg>! zXW?g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Date: Thu, 18 Oct 2018 12:15:58 -0600 Subject: [PATCH 07/16] MetaFixers update --- .../MSFT_xWebConfigProperty.psm1 | Bin 22892 -> 17169 bytes .../MSFT_xWebConfigProperty.schema.mof | Bin 1312 -> 646 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 2e30be79d1e4e688fea3f443622c53a6ad7c5196..5676d23597c0e70cfd9256265b98323487c36ba5 100644 GIT binary patch literal 17169 zcmeHPYjfMS68-C96Q-8OO03vytcf+DY|)Z$^{`|zHJk9>zoLQh_}IU2&jKI_QIsO3 zY9{xNXEK?_CW*yjALr~Y`q!8Lu-2_C&SZEilZlM}WWi8IQ`LEt{ekKvt8qt$Lm8(0 zA(oxFTnyCxz3e73e2pLCx2x<6Yn`%I%+6woKZ{I7sf?EFq>yZg!fWeELk>H-3ys4Wq)Qq$kMp>6W)qf>BuZ0u423^iyIj|%J5S5mkN>$Udc`( zli&46><`Uy`1?7HIi!lla(XNCdlrmjamRwC9HcBr)F4rvdkKL%GyGHb=8A+|%IHCL zmn_KD5s(JVLOjn^cP@)JGS8s@Quso(&s8wTS}I9txj-)$$Eq`sPf*lco?vSU z3uf39y_*mBU9p#|XfC_6axFR?*4nw^K5KOnIuUm?-B5M!Rktm(WPKr8OXi`%IqK8j zuJ(I%hMgv>6rz%ut=T|yA-bv6XFJ6zsyF9Jf&*p2)U5~`5ZjJb8-VJhtOes=%3>;$ z&oHDldGZ`u<*gC^US-89J$-&SU8T3|=~N^aym%`*=c3d0H2*6;sLr+3LHKrtFRSiM zUBNqW^qKq$Be^pc2q!XTtWI#O2^~rYh6f{ga7T~5V^J)}!*d?K=TV18mn?WMqYtWc z0}Ts2-yN*7u~iX16~ZHEU6=&+j^DCiEQ?fK#}XctJd({jyDi`sGd>(+7g{!$j#{VI+tK`s1)eiY@Ez zug`sRE#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aWW|7*&<)ypLF zZIG!-t<=|v@ z@)@}HHw3SMnZMg5){%3UE4`Y%h;7i;-2k-Pa(cT>WQ9AX+zn~s^dfKP6=X*kXj4g*TZ7eMsC!&JetFL0E^n1q{pji)n(EyP?#SGymd$QV=TQayUD|QJ zO(Nexdw8O6uCO}fH0rPlD%nr(qUPe4)mnJz))?Nm(YC5TsNZ__s{PxnjgHObRbk}q ze%>@j@lX26I}w;Y&|P9#e*5Tu*|Cc<0w#ePpEchUt&_A1cyRW9lT^|)GD|r!fQ-^# z+{Mk%bBv`A$ehzDG-8OVrRVsM{vYoV^OpGzVkdg6^fdT(8PTyH@O*-Iz{m~wQPhdN zW@rl#MavH1Y(0 z*C#TT@1dSz+O5vNeyIMn+B>djIl^jVHA^yJ)>qz~r1qq0HRQb|qAPhk(%#R`@zk0~ zQg$C+H!IvU|JZrmxyATY{XOr4td7Rc>sGte?$$}J`)YgqK2`O)+k3s$xuDse1krOOI)_qFw2u zFL*ewoIi!%nEQHsj~Q$BSy_94-L2~T`RDXMf5PW&9KqdafHw|VCWX0rzmgnFd(X@l z{YRcE>|+*{J@%J-K2-{=Pjww+A2gpc-!JLiUSMY3-)u&5&EU23DbsrgK4+WH%lCEB zFXx-{e8jK$!~<|b$B-|qU*X9{)hBK8Idg4RO1)I%eZ0pj{)F6wIs(S_CQ6Br`Me1S z-tow9O8EILtEcqW%_lR}`!VSXRPT1!Oq~BdJQcTO zvQ+u8tEEe*lKW_&Em$v*r% wjg=P61I@7izJP=s$BLAb_|CCQ?B~oM$zGnGa`wV+Fv8bFY@@HQd?Nh+0TfX#(f|Me diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof index da70b0b2582d966d3231dfedb4b88ac2f078c10e..d2a7576a90963809a07342935f4390aefbb0b182 100644 GIT binary patch literal 646 zcma)2!Ab)$6uj?OJaXE?QuJz1wOUxDTCB8(A|<iZujZU@ZwiK3Eb6*D zXU@#*?Dtm>w+Jyn!lMHpOa9IfVSzJvxI`5f`Nu;A=P;-fH6wO`F=y9!kxNF6Y zBc98SPyIGT%hAIFudmg|ouWtTCWbBfZjsMoO1veT!8?&dO~&%fP<2Fp!MLmpy*GHY zc`qWLNmHmXp*b-NeiEXWTQh-T=X$NelwB@{EP|A&NzNosMRsS(u8(k4Cr79(qHsk; zKJ{fD3s2%Orh@V_%TO!c8LMJ{uj2BaV{~SHk}Lz&H`UbtqG`8-*^XU(T}@t+mZtA- zNJHB{OIskVGfek)wF8|ocw>Gc^Ou|xwoLjO>XR7eK7~=VDT%aav5fR*9ERzO~7-nD2$BZ)Sn@=-ET9w8z6nb0}t$gXj9(x!vS@`bnr)^c|af Pq2xc?QLs8)n^fNqCyn4v From 8bcedc78c7a09527826f369239699c956d13d891 Mon Sep 17 00:00:00 2001 From: Geoffrey Guynn Date: Sun, 21 Oct 2018 19:41:38 -0600 Subject: [PATCH 08/16] formatting error --- .../MSFT_xWebConfigProperty.psm1 | 445 +++++++++++++++++- 1 file changed, 444 insertions(+), 1 deletion(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 5676d2359..60ada5264 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -1 +1,444 @@ -‣潌慣楬敺⁤敭獳条獥਍慤慴䰠捯污穩摥慄慴਍ൻ †⌠挠汵畴敲∽湥唭≓਍††潃癮牥䙴潲⵭瑓楲杮慄慴ⴠ瑓楲杮慄慴䀠ധ †嘠牥潢敳慔杲瑥桃捥楫杮慔杲瑥†††㴠䌠敨正湩⁧潦⁲桴⁥硥獩整据⁥景瀠潲数瑲⁹笢細•獵湩⁧楦瑬牥∠ㅻ≽氠捯瑡摥愠⁴笢紲⸢਍††敖扲獯呥牡敧側潲数瑲乹瑯潆湵⁤††‽牐灯牥祴∠ほ≽栠獡渠瑯戠敥潦湵⹤਍††敖扲獯呥牡敧側潲数瑲䙹畯摮††††‽牐灯牥祴∠ほ≽栠獡戠敥潦湵⹤਍††敖扲獯卥瑥慔杲瑥摅瑩瑉浥†††††‽湅畳楲杮瀠潲数瑲⁹笢細•獩猠瑥മ †嘠牥潢敳敓呴牡敧剴浥癯䥥整†††㴠倠潲数瑲⁹笢細•硥獩獴‬敲潭楶杮瀠潲数瑲⹹਍䀧਍ൽഊ㰊ണ⸊奓低卐卉਍††敇獴琠敨挠牵敲瑮瘠污敵漠⁦桴⁥慴杲瑥爠獥畯捲⁥牰灯牥祴മഊ⸊䅐䅒䕍䕔⁒敗獢瑩健瑡൨ †删煥極敲⹤倠瑡⁨潴眠扥楳整氠捯瑡潩䤨卉漠⁲敗䅢浤湩獩牴瑡潩潦浲瑡⸩਍਍倮剁䵁呅剅䘠汩整൲ †删煥極敲⹤䘠汩整⁲獵摥琠潬慣整瀠潲数瑲⁹潴甠摰瑡⹥਍਍倮剁䵁呅剅䰠捯瑡潩൮ †删煥極敲⹤䰠捯瑡潩慴⁧潴甠敳映牯瀠潲数瑲⹹਍਍倮剁䵁呅剅倠潲数瑲乹浡൥ †删煥極敲⹤丠浡⁥景琠敨瀠潲数瑲⁹潴甠摰瑡⹥਍㸣਍畦据楴湯䜠瑥吭牡敧剴獥畯捲൥笊਍††䍛摭敬䉴湩楤杮⤨൝ †嬠畏灴瑵祔数嬨祓瑳浥䌮汯敬瑣潩獮䠮獡瑨扡敬⥝൝ †瀠牡浡਍††ന †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠敗獢瑩健瑡ⱨ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††䘤汩整Ⱳ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††䅛汬睯浅瑰卹牴湩⡧崩਍††††獛牴湩嵧਍††††䰤捯瑡潩Ɱ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††値潲数瑲乹浡൥ †⤠਍††‣敒牴敩敶琠敨瘠污敵漠⁦桴⁥硥獩楴杮瀠潲数瑲⁹晩瀠敲敳瑮മ †圠楲整嘭牥潢敳ⴠ敍獳条⁥␨潌慣楬敺䑤瑡⹡敖扲獯呥牡敧䍴敨正湩呧牡敧⁴昭␠牐灯牥祴慎敭‬䘤汩整Ⱳ␠敗獢瑩健瑡⥨਍਍††䜤瑥䥟整噭污敵灟牡浡㴠䀠ൻ †††圠扥楳整慐桴㴠␠敗獢瑩健瑡൨ †††䘠汩整⁲‽䘤汩整൲ †††䰠捯瑡潩‽䰤捯瑡潩൮ †††倠潲数瑲乹浡⁥‽値潲数瑲乹浡൥ †素਍਍††攤楸瑳湩噧污敵㴠䜠瑥䤭整噭污敵䀠敇彴瑉浥慖畬彥慰慲൭ഊ †␠敲畳瑬㴠䀠ൻ †††圠扥楳整慐桴㴠␠敗獢瑩健瑡൨ †††䘠汩整⁲‽䘤汩整൲ †††䰠捯瑡潩‽䰤捯瑡潩൮ †††倠潲数瑲乹浡⁥‽値潲数瑲乹浡൥ †††䔠獮牵⁥‽倧敲敳瑮ധ †††嘠污敵㴠␠硥獩楴杮慖畬൥ †素਍਍††晩⠠ⴠ潮⡴攤楸瑳湩噧污敵

ൻ †††⌠倠潲数瑲⁹慷⁳潮⁴潦湵⹤਍††††牗瑩ⵥ敖扲獯⁥䴭獥慳敧⠠䰤捯污穩摥慄慴嘮牥潢敳慔杲瑥牐灯牥祴潎䙴畯摮ⴠ⁦値潲数瑲乹浡⥥਍਍††††爤獥汵⹴湅畳敲㴠✠扁敳瑮ധ †素਍††汥敳笠਍††††‣牐灯牥祴眠獡映畯摮മ †††圠楲整嘭牥潢敳ⴠ敍獳条⁥␨潌慣楬敺䑤瑡⹡敖扲獯呥牡敧側潲数瑲䙹畯摮ⴠ⁦値潲数瑲乹浡⥥਍††ൽഊ †爠瑥牵爤獥汵൴紊਍਍⌼਍匮乙偏䥓൓ †匠瑥⁳桴⁥慶畬⁥景琠敨琠牡敧⁴敲潳牵散瀠潲数瑲⹹਍਍倮剁䵁呅剅圠扥楳整慐桴਍††敒畱物摥‮慐桴琠敷獢瑩⁥潬慣楴湯⠠䥉⁓牯圠扥摁業楮瑳慲楴湯映牯慭⥴മഊ⸊䅐䅒䕍䕔⁒楆瑬牥਍††敒畱物摥‮楆瑬牥甠敳⁤潴氠捯瑡⁥牰灯牥祴琠灵慤整മഊ⸊䅐䅒䕍䕔⁒潌慣楴湯਍††敒畱物摥‮潌慣楴湯琠条琠獵⁥潦⁲牰灯牥祴മഊ⸊䅐䅒䕍䕔⁒牐灯牥祴慎敭਍††敒畱物摥‮慎敭漠⁦桴⁥牰灯牥祴琠灵慤整മഊ⸊䅐䅒䕍䕔⁒慖畬൥ †嘠污敵漠⁦桴⁥牰灯牥祴琠灵慤整മഊ⸊䅐䅒䕍䕔⁒湅畳敲਍††牐獥湥⁴牯䄠獢湥⹴䐠晥畡瑬⁳潴倠敲敳瑮മ⌊ാ昊湵瑣潩敓⵴慔杲瑥敒潳牵散਍ൻ †嬠浃汤瑥楂摮湩⡧崩਍††慰慲൭ †⠠਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††圤扥楳整慐桴ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠楆瑬牥ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠汁潬䕷灭祴瑓楲杮⤨൝ †††嬠瑳楲杮൝ †††␠潌慣楴湯ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠牐灯牥祴慎敭ബഊ †††嬠慐慲敭整⡲崩਍††††獛牴湩嵧਍††††嘤污敵ബഊ †††嬠慐慲敭整⡲崩਍††††噛污摩瑡卥瑥✨牐獥湥❴✬扁敳瑮⤧൝ †††嬠瑳楲杮൝ †††␠湅畳敲㴠✠牐獥湥❴਍††ഩ †椠⁦␨湅畳敲ⴠ煥✠牐獥湥❴
ൻ †††⌠倠潲数瑲⁹敮摥⁳潴戠⁥灵慤整⹤਍††††牗瑩ⵥ敖扲獯⁥䴭獥慳敧⠠䰤捯污穩摥慄慴嘮牥潢敳敓呴牡敧䕴楤䥴整昭␠牐灯牥祴慎敭ഩ †††ഠ †††␠敇彴瑉浥牐灯牥祴祔数灟牡浡㴠䀠ൻ †††††圠扥楳整慐桴㴠␠敗獢瑩健瑡൨ †††††䘠汩整⁲‽䘤汩整⁲਍††††††潌慣楴湯㴠␠潌慣楴湯਍††††††牐灯牥祴慎敭㴠␠牐灯牥祴慎敭††††਍††††ൽഊ †††␠牰灯牥祴祔数㴠䜠瑥䤭整偭潲数瑲呹灹⁥䝀瑥䥟整偭潲数瑲呹灹彥慰慲൭ഊ †††椠⁦␨牰灯牥祴祔数ⴠ慭捴⁨䤧瑮㈳䥼瑮㐶⤧ഠ †††††笠␠敳噴污敵㴠䌠湯敶瑲倭潲数瑲噹污敵ⴠ牐灯牥祴祔数␠牰灯牥祴祔数ⴠ湉異噴污敵␠慖畬⁥ൽ †††攠獬⁥਍††††††⁻猤瑥慖畬⁥‽嘤污敵素਍਍††††匤瑥坟扥潃普杩牵瑡潩偮潲数瑲役慰慲‽筀਍††††††卐慐桴㴠␠敗獢瑩健瑡൨ †††††䘠汩整⁲‽䘤汩整൲ †††††䰠捯瑡潩‽䰤捯瑡潩൮ †††††丠浡⁥‽値潲数瑲乹浡൥ †††††嘠污敵㴠␠敳噴污敵਍††††††慗湲湩䅧瑣潩‽匢潴≰਍††††ൽഊ †††匠瑥圭扥潃普杩牵瑡潩偮潲数瑲⁹區瑥坟扥潃普杩牵瑡潩偮潲数瑲役慰慲൭ †素਍††汥敳笠਍††††‣牐灯牥祴渠敥獤琠敢爠浥癯摥മ †††圠楲整嘭牥潢敳ⴠ敍獳条⁥␨潌慣楬敺䑤瑡⹡敖扲獯卥瑥慔杲瑥敒潭敶瑉浥ⴠ⁦値潲数瑲乹浡⥥਍††††਍††††䌤敬牡坟扥潃普杩牵瑡潩彮慰慲‽筀਍††††††卐慐桴㴠␠敗獢瑩健瑡൨ †††††䘠汩整⁲∽⠤䘤汩整⥲䀯⠤値潲数瑲乹浡⥥ഢ †††††䰠捯瑡潩‽䰤捯瑡潩൮ †††††圠牡楮杮捁楴湯㴠∠瑓灯ഢ †††素਍਍††††汃慥⵲敗䍢湯楦畧慲楴湯䀠汃慥彲敗䍢湯楦畧慲楴湯灟牡浡਍††ൽ紊਍਍⌼਍匮乙偏䥓൓ †吠獥獴琠敨瘠污敵漠⁦桴⁥慴杲瑥爠獥畯捲⁥牰灯牥祴മഊ⸊䅐䅒䕍䕔⁒敗獢瑩健瑡൨ †删煥極敲⹤倠瑡⁨潴眠扥楳整氠捯瑡潩䤨卉漠⁲敗䅢浤湩獩牴瑡潩潦浲瑡⸩਍਍倮剁䵁呅剅䘠汩整൲ †删煥極敲⹤䘠汩整⁲獵摥琠潬慣整瀠潲数瑲⁹潴甠摰瑡⹥਍਍倮剁䵁呅剅䰠捯瑡潩൮ †删煥極敲⹤䰠捯瑡潩慴⁧潴甠敳映牯瀠潲数瑲⹹਍਍倮剁䵁呅剅倠潲数瑲乹浡൥ †删煥極敲⹤丠浡⁥景琠敨瀠潲数瑲⁹潴甠摰瑡⹥਍਍倮剁䵁呅剅嘠污敵਍††慖畬⁥景琠敨瀠潲数瑲⁹潴甠摰瑡⹥਍਍倮剁䵁呅剅䔠獮牵൥ †倠敲敳瑮漠⁲扁敳瑮‮敄慦汵獴琠牐獥湥⹴਍㸣਍畦据楴湯吠獥⵴慔杲瑥敒潳牵散਍ൻ †嬠浃汤瑥楂摮湩⡧崩਍††佛瑵異呴灹⡥卛獹整⹭潂汯慥嵮崩਍††慰慲൭ †⠠਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††圤扥楳整慐桴ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠楆瑬牥ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠汁潬䕷灭祴瑓楲杮⤨൝ †††嬠瑳楲杮൝ †††␠潌慣楴湯ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠牐灯牥祴慎敭ബഊ †††嬠慐慲敭整⡲崩਍††††獛牴湩嵧਍††††嘤污敵ബഊ †††嬠慐慲敭整⡲崩਍††††噛污摩瑡卥瑥✨牐獥湥❴✬扁敳瑮⤧൝ †††嬠瑳楲杮൝ †††␠湅畳敲㴠✠牐獥湥❴਍††ഩ †⌠删瑥楲癥⁥桴⁥慶畬⁥景琠敨攠楸瑳湩⁧牰灯牥祴椠⁦牰獥湥⹴਍††牗瑩ⵥ敖扲獯⁥䴭獥慳敧⠠䰤捯污穩摥慄慴嘮牥潢敳慔杲瑥桃捥楫杮慔杲瑥ⴠ⁦値潲数瑲乹浡ⱥ␠楆瑬牥‬圤扥楳整慐桴ഩഊ †␠敇彴慔杲瑥敒潳牵散灟牡浡㴠䀠ൻ †††圠扥楳整慐桴㴠␠敗獢瑩健瑡൨ †††䘠汩整⁲‽䘤汩整൲ †††倠潲数瑲乹浡⁥‽値潲数瑲乹浡൥ †††䰠捯瑡潩‽䰤捯瑡潩൮ †素਍਍††琤牡敧剴獥畯捲⁥‽敇⵴慔杲瑥敒潳牵散䀠敇彴慔杲瑥敒潳牵散灟牡浡਍਍††晩⠠䔤獮牵⁥攭ⁱ倧敲敳瑮⤧笠਍††††晩⠠⠠渤汵攭ⁱ琤牡敧剴獥畯捲⹥慖畬⥥ⴠ牯⠠琤牡敧剴獥畯捲⹥慖畬⹥潔瑓楲杮⤨ⴠ敮␠慖畬⥥⤠笠਍††††††‣牐灯牥祴眠獡渠瑯映畯摮漠⁲楤湤琧栠癡⁥硥数瑣摥瘠污敵മ †††††圠楲整嘭牥潢敳ⴠ敍獳条⁥␨潌慣楬敺䑤瑡⹡敖扲獯呥牡敧側潲数瑲乹瑯潆湵⁤昭␠牐灯牥祴慎敭ഩഊ †††††爠瑥牵昤污敳਍††††ൽ †素਍††汥敳笠਍††††晩⠠⠠渤汵渭⁥琤牡敧剴獥畯捲⹥慖畬⥥ⴠ湡⁤␨慴杲瑥敒潳牵散嘮污敵吮卯牴湩⡧⸩敌杮桴ⴠ敮〠⤠⤠笠਍††††††‣牐灯牥祴眠獡映畯摮മ †††††圠楲整嘭牥潢敳ⴠ敍獳条⁥␨潌慣楬敺䑤瑡⹡敖扲獯呥牡敧側潲数瑲坹獡潆湵⁤昭␠牐灯牥祴慎敭ഩഊ †††††爠瑥牵昤污敳਍††††ൽ †素਍਍††牗瑩ⵥ敖扲獯⁥䴭獥慳敧⠠䰤捯污穩摥慄慴嘮牥潢敳慔杲瑥牐灯牥祴慗䙳畯摮ⴠ⁦値潲数瑲乹浡⥥਍਍††敲畴湲␠牴敵਍ൽഊ⌊爠来潩效灬牥䘠湵瑣潩獮਍਍⌼਍匮乙偏䥓൓ †䜠瑥⁳桴⁥畣牲湥⁴慶畬⁥景琠敨瀠潲数瑲⹹਍਍倮剁䵁呅剅圠扥楳整慐桴਍††敒畱物摥‮慐桴琠敷獢瑩⁥潬慣楴湯⠠䥉⁓牯圠扥摁業楮瑳慲楴湯映牯慭⥴മഊ⸊䅐䅒䕍䕔⁒楆瑬牥਍††敒畱物摥‮楆瑬牥甠敳⁤潴氠捯瑡⁥牰灯牥祴琠敲牴敩敶മഊ⸊䅐䅒䕍䕔⁒潌慣楴湯਍††灏楴湯污‮潌慣楴湯琠条琠獵⁥潦⁲牰灯牥祴മഊ⸊䅐䅒䕍䕔⁒牐灯牥祴慎敭਍††敒畱物摥‮慎敭漠⁦桴⁥牰灯牥祴琠敲牴敩敶മ⌊ാ昊湵瑣潩敇⵴瑉浥慖畬൥笊਍††䍛摭敬䉴湩楤杮⤨൝ †嬠畏灴瑵祔数嬨祓瑳浥伮橢捥嵴崩਍††慰慲൭ †⠠਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††圤扥楳整慐桴ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠楆瑬牥ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽昤污敳崩਍††††獛牴湩嵧਍††††䰤捯瑡潩Ɱ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††値潲数瑲乹浡൥ †⤠਍਍††‣敒牴敩敶琠敨瘠污敵漠⁦桴⁥灳捥晩敩⁤牰灯牥祴椠⁦牰獥湥⹴਍††䜤瑥坟扥潃普杩牵瑡潩偮潲数瑲役慰慲‽筀਍††††卐慐桴㴠␠敗獢瑩健瑡൨ †††䘠汩整⁲‽䘤汩整൲ †††丠浡⁥‽値潲数瑲乹浡൥ †††䰠捯瑡潩‽䰤捯瑡潩൮ †素਍††਍††瘤污敵㴠䜠瑥圭扥潃普杩牵瑡潩偮潲数瑲⁹䝀瑥坟扥潃普杩牵瑡潩偮潲数瑲役慰慲൭ഊ †⌠删瑥牵桴⁥慶畬⁥景琠敨瀠潲数瑲⁹晩氠捯瑡摥മ †椠⁦␨慶畬⁥椭⁳䵛捩潲潳瑦䤮獉倮睯牥桓汥⹬牆浡睥牯⹫潃普杩牵瑡潩䅮瑴楲畢整⥝笠਍††††敲畴湲␠慶畬⹥慖畬൥ †素਍††敲畴湲␠慶畬൥紊਍਍⌼਍匮乙偏䥓൓ †䜠瑥⁳桴⁥畣牲湥⁴慤慴琠灹⁥景琠敨瀠潲数瑲⹹਍਍倮剁䵁呅剅圠扥楳整慐桴਍††敒畱物摥‮慐桴琠敷獢瑩⁥潬慣楴湯⠠䥉⁓牯圠扥摁業楮瑳慲楴湯映牯慭⥴മഊ⸊䅐䅒䕍䕔⁒楆瑬牥਍††敒畱物摥‮楆瑬牥甠敳⁤潴氠捯瑡⁥牰灯牥祴琠敲牴敩敶മഊ⸊䅐䅒䕍䕔⁒潌慣楴湯਍††灏楴湯污‮潌慣楴湯琠条琠獵⁥潦⁲牰灯牥祴മ †ഠ⸊䅐䅒䕍䕔⁒牐灯牥祴慎敭਍††敒畱物摥‮慎敭漠⁦桴⁥牰灯牥祴琠敲牴敩敶മ⌊ാ昊湵瑣潩敇⵴瑉浥牐灯牥祴祔数਍ൻ †嬠浃汤瑥楂摮湩⡧崩਍††佛瑵異呴灹⡥卛獹整⹭瑓楲杮⥝൝ †瀠牡浡਍††ന †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠敗獢瑩健瑡ⱨ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠牴敵崩਍††††噛污摩瑡乥瑯畎汬牏浅瑰⡹崩਍††††獛牴湩嵧਍††††䘤汩整Ⱳ਍਍††††偛牡浡瑥牥䴨湡慤潴祲㴠␠慦獬⥥൝ †††嬠瑳楲杮൝ †††␠潌慣楴湯ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠慖楬慤整潎乴汵佬䕲灭祴⤨൝ †††嬠瑳楲杮൝ †††␠牐灯牥祴慎敭਍††ഩഊ †␠敇彴敗䍢湯楦畧慲楴湯灟牡浡㴠䀠ൻ †††䘠汩整⁲‽䘤汩整⁲਍††††獐慐桴㴠␠敗獢瑩健瑡൨ †††䰠捯瑡潩‽䰤捯瑡潩൮ †素਍਍††眤扥潃普杩牵瑡潩‽敇⵴敗䍢湯楦畧慲楴湯䀠敇彴敗䍢湯楦畧慲楴湯灟牡浡਍਍††瀤潲数瑲⁹‽眤扥潃普杩牵瑡潩⹮捓敨慭䄮瑴楲畢整捓敨慭⁳⁼桗牥ⵥ扏敪瑣ⴠ楆瑬牥捓楲瑰笠␠⹟慎敭ⴠ煥␠牰灯牥祴慎敭素਍਍††敲畴湲␠牰灯牥祴䌮牬祔数丮浡൥紊਍਍⌼਍匮乙偏䥓൓ †䌠湯敶瑲⁳桴⁥牰灯牥祴映潲瑳楲杮琠灡牰灯楲瑡⁥慤慴琠灹⹥਍਍倮剁䵁呅剅倠潲数瑲呹灹൥ †倠潲数瑲⁹祴数琠敢挠湯敶瑲摥琠⹯਍਍倮剁䵁呅剅䤠灮瑵慖畬൥ †嘠污敵琠敢挠湯敶瑲摥മ⌊ാ昊湵瑣潩潃癮牥⵴牐灯牥祴慖畬൥笊਍††䍛摭敬䉴湩楤杮⤨൝ †嬠畏灴瑵祔数嬨祓瑳浥嘮污敵祔数⥝൝ †瀠牡浡਍††ന †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠瑳楲杮൝ †††␠牐灯牥祴祔数ബഊ †††嬠慐慲敭整⡲慍摮瑡牯⁹‽琤畲⥥൝ †††嬠瑳楲杮൝ †††␠湉異噴污敵਍††ഩഊ †猠楷捴⁨␨牐灯牥祴祔数⤠਍††ൻ †††✠湉㍴✲਍††††ൻ †††††嬠湉㍴崲␠慶畬⁥‽捛湯敶瑲㩝吺䥯瑮㈳␨湉異噴污敵‬〱ഩ †††素਍††††唧湉㍴✲਍††††ൻ †††††嬠䥕瑮㈳⁝瘤污敵㴠嬠潣癮牥嵴㨺潔䥕瑮㈳␨湉異噴污敵‬〱ഩ †††素਍††††䤧瑮㐶ധ †††笠਍††††††䥛瑮㐶⁝瘤污敵㴠嬠潣癮牥嵴㨺潔湉㙴⠴䤤灮瑵慖畬ⱥㄠ⤰਍††††ൽ †素਍਍††敲畴湲␠慶畬൥紊਍਍‣湥牤来潩൮ഊ䔊灸牯⵴潍畤敬敍扭牥ⴠ畆据楴湯⨠吭牡敧剴獥畯捲൥ \ No newline at end of file +# Localized messages +data LocalizedData +{ + # culture="en-US" + ConvertFrom-StringData -StringData @' + VerboseTargetCheckingTarget = Checking for the existence of property "{0}" using filter "{1}" located at "{2}". + VerboseTargetPropertyNotFound = Property "{0}" has not been found. + VerboseTargetPropertyFound = Property "{0}" has been found. + VerboseSetTargetEditItem = Ensuring property "{0}" is set. + VerboseSetTargetRemoveItem = Property "{0}" exists, removing property. +'@ +} + +<# +.SYNOPSIS + Gets the current value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. +#> +function Get-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Collections.Hashtable])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + # Retrieve the value of the existing property if present. + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) + + $Get_ItemValue_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + Location = $Location + PropertyName = $PropertyName + } + + $existingValue = Get-ItemValue @Get_ItemValue_param + + $result = @{ + WebsitePath = $WebsitePath + Filter = $Filter + Location = $Location + PropertyName = $PropertyName + Ensure = 'Present' + Value = $existingValue + } + + if ( -not($existingValue) ) { + # Property was not found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) + + $result.Ensure = 'Absent' + } + else { + # Property was found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) + } + + return $result +} + +<# +.SYNOPSIS + Sets the value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. + +.PARAMETER Value + Value of the property to update. + +.PARAMETER Ensure + Present or Absent. Defaults to Present. +#> +function Set-TargetResource +{ + [CmdletBinding()] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName, + + [Parameter()] + [string] + $Value, + + [Parameter()] + [ValidateSet('Present','Absent')] + [string] + $Ensure = 'Present' + ) + if ($Ensure -eq 'Present') { + # Property needs to be updated. + Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) + + $Get_ItemPropertyType_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + Location = $Location + PropertyName = $PropertyName + } + + $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param + + if ($propertyType -match 'Int32|Int64') + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } + else + { $setValue = $Value } + + $Set_WebConfigurationProperty_param = @{ + PSPath = $WebsitePath + Filter = $Filter + Location = $Location + Name = $PropertyName + Value = $setValue + WarningAction = "Stop" + } + + Set-WebConfigurationProperty @Set_WebConfigurationProperty_param + } + else { + # Property needs to be removed. + Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) + + $Clear_WebConfiguration_param = @{ + PSPath = $WebsitePath + Filter ="$($Filter)/@$($PropertyName)" + Location = $Location + WarningAction = "Stop" + } + + Clear-WebConfiguration @Clear_WebConfiguration_param + } +} + +<# +.SYNOPSIS + Tests the value of the target resource property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to update. + +.PARAMETER Location + Required. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to update. + +.PARAMETER Value + Value of the property to update. + +.PARAMETER Ensure + Present or Absent. Defaults to Present. +#> +function Test-TargetResource +{ + [CmdletBinding()] + [OutputType([System.Boolean])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName, + + [Parameter()] + [string] + $Value, + + [Parameter()] + [ValidateSet('Present','Absent')] + [string] + $Ensure = 'Present' + ) + # Retrieve the value of the existing property if present. + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) + + $Get_TargetResource_param = @{ + WebsitePath = $WebsitePath + Filter = $Filter + PropertyName = $PropertyName + Location = $Location + } + + $targetResource = Get-TargetResource @Get_TargetResource_param + + if ($Ensure -eq 'Present') { + if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { + # Property was not found or didn't have expected value. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) + + return $false + } + } + else { + if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { + # Property was found. + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + + return $false + } + } + + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + + return $true +} + +# region Helper Functions + +<# +.SYNOPSIS + Gets the current value of the property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to retrieve. + +.PARAMETER Location + Optional. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to retrieve. +#> +function Get-ItemValue +{ + [CmdletBinding()] + [OutputType([System.Object])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $false)] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + + # Retrieve the value of the specified property if present. + $Get_WebConfigurationProperty_param = @{ + PSPath = $WebsitePath + Filter = $Filter + Name = $PropertyName + Location = $Location + } + + $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param + + # Return the value of the property if located. + if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { + return $value.Value + } + return $value +} + +<# +.SYNOPSIS + Gets the current data type of the property. + +.PARAMETER WebsitePath + Required. Path to website location (IIS or WebAdministration format). + +.PARAMETER Filter + Required. Filter used to locate property to retrieve. + +.PARAMETER Location + Optional. Location tag to use for property. + +.PARAMETER PropertyName + Required. Name of the property to retrieve. +#> +function Get-ItemPropertyType +{ + [CmdletBinding()] + [OutputType([System.String])] + param + ( + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $WebsitePath, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $Filter, + + [Parameter(Mandatory = $false)] + [string] + $Location, + + [Parameter(Mandatory = $true)] + [ValidateNotNullOrEmpty()] + [string] + $PropertyName + ) + + $Get_WebConfiguration_param = @{ + Filter = $Filter + PsPath = $WebsitePath + Location = $Location + } + + $webConfiguration = Get-WebConfiguration @Get_WebConfiguration_param + + $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } + + return $property.ClrType.Name +} + +<# +.SYNOPSIS + Converts the property from string to appropriate data type. + +.PARAMETER PropertyType + Property type to be converted to. + +.PARAMETER InputValue + Value to be converted. +#> +function Convert-PropertyValue +{ + [CmdletBinding()] + [OutputType([System.ValueType])] + param + ( + [Parameter(Mandatory = $true)] + [string] + $PropertyType, + + [Parameter(Mandatory = $true)] + [string] + $InputValue + ) + + switch ($PropertyType ) + { + 'Int32' + { + [Int32] $value = [convert]::ToInt32($InputValue, 10) + } + 'UInt32' + { + [UInt32] $value = [convert]::ToUInt32($InputValue, 10) + } + 'Int64' + { + [Int64] $value = [convert]::ToInt64($InputValue, 10) + } + } + + return $value +} + +# endregion + +Export-ModuleMember -Function *-TargetResource From aee385443728eb113ebf97aa45a9f16b4c9c37fb Mon Sep 17 00:00:00 2001 From: Geoffrey Guynn Date: Mon, 22 Oct 2018 11:33:24 -0600 Subject: [PATCH 09/16] UnitTestingUpdate1 --- .../MSFT_xWebConfigProperty.psm1 | 20 +++++++++---------- .../MSFT_xWebConfigProperty.schema.mof | 1 + 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 60ada5264..d43c4b18c 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -1,4 +1,4 @@ -# Localized messages +# Localized messages data LocalizedData { # culture="en-US" @@ -147,19 +147,19 @@ function Set-TargetResource if ($Ensure -eq 'Present') { # Property needs to be updated. Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - + $Get_ItemPropertyType_param = @{ WebsitePath = $WebsitePath - Filter = $Filter + Filter = $Filter Location = $Location - PropertyName = $PropertyName + PropertyName = $PropertyName } $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param - if ($propertyType -match 'Int32|Int64') + if ($propertyType -match 'Int32|Int64') { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } - else + else { $setValue = $Value } $Set_WebConfigurationProperty_param = @{ @@ -176,7 +176,7 @@ function Set-TargetResource else { # Property needs to be removed. Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) - + $Clear_WebConfiguration_param = @{ PSPath = $WebsitePath Filter ="$($Filter)/@$($PropertyName)" @@ -330,7 +330,7 @@ function Get-ItemValue Name = $PropertyName Location = $Location } - + $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param # Return the value of the property if located. @@ -352,7 +352,7 @@ function Get-ItemValue .PARAMETER Location Optional. Location tag to use for property. - + .PARAMETER PropertyName Required. Name of the property to retrieve. #> @@ -383,7 +383,7 @@ function Get-ItemPropertyType ) $Get_WebConfiguration_param = @{ - Filter = $Filter + Filter = $Filter PsPath = $WebsitePath Location = $Location } diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof index d2a7576a9..1ed4cfa88 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof @@ -4,6 +4,7 @@ class MSFT_xWebConfigProperty : OMI_BaseResource [Key, Description("Path to website location (IIS or WebAdministration format).")] String WebsitePath; [Key, Description("Filter used to locate property to update.")] String Filter; [Key, Description("Name of the property to update.")] String PropertyName; + [Key, Description("Location is used to update locked sections in the root config.")] String Location; [Write, Description("Indicates if the property and value should be present or absent. Defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Write, Description("Value of the property to update.")] String Value; }; From 7380af32fc5ce6c134a0d5f96ce2a504d96ee54b Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Thu, 24 Jan 2019 11:19:23 -0700 Subject: [PATCH 10/16] CodeCov modifications --- .../MSFT_xWebConfigProperty.psm1 | 95 +++++++------------ 1 file changed, 34 insertions(+), 61 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index d43c4b18c..54815b674 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -54,16 +54,13 @@ function Get-TargetResource $PropertyName ) # Retrieve the value of the existing property if present. - Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - - $Get_ItemValue_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - Location = $Location - PropertyName = $PropertyName - } + Write-Verbose ` + -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $existingValue = Get-ItemValue @Get_ItemValue_param + $existingValue = Get-ItemValue -WebsitePath $WebsitePath ` + -Filter $Filter ` + -Location $Location ` + -PropertyName $PropertyName $result = @{ WebsitePath = $WebsitePath @@ -147,44 +144,32 @@ function Set-TargetResource if ($Ensure -eq 'Present') { # Property needs to be updated. Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - - $Get_ItemPropertyType_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - Location = $Location - PropertyName = $PropertyName - } - $propertyType = Get-ItemPropertyType @Get_ItemPropertyType_param + $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath ` + -Filter $Filter ` + -Location $Location ` + -PropertyName $PropertyName - if ($propertyType -match 'Int32|Int64') + if ($propertyType -match 'Int32|Int64') { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } - else + else { $setValue = $Value } - $Set_WebConfigurationProperty_param = @{ - PSPath = $WebsitePath - Filter = $Filter - Location = $Location - Name = $PropertyName - Value = $setValue - WarningAction = "Stop" - } - - Set-WebConfigurationProperty @Set_WebConfigurationProperty_param + Set-WebConfigurationProperty -PSPath $WebsitePath ` + -Filter $Filter ` + -Location $Location ` + -Name $PropertyName ` + -Value $setValue ` + -WarningAction "Stop" } else { # Property needs to be removed. Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) - - $Clear_WebConfiguration_param = @{ - PSPath = $WebsitePath - Filter ="$($Filter)/@$($PropertyName)" - Location = $Location - WarningAction = "Stop" - } - Clear-WebConfiguration @Clear_WebConfiguration_param + Clear-WebConfiguration -PSPath $WebsitePath ` + -Filter "$($Filter)/@$($PropertyName)" ` + -Location $Location ` + -WarningAction "Stop" } } @@ -248,14 +233,10 @@ function Test-TargetResource # Retrieve the value of the existing property if present. Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $Get_TargetResource_param = @{ - WebsitePath = $WebsitePath - Filter = $Filter - PropertyName = $PropertyName - Location = $Location - } - - $targetResource = Get-TargetResource @Get_TargetResource_param + $targetResource = Get-TargetResource -WebsitePath $WebsitePath ` + -Filter $Filter ` + -PropertyName $PropertyName ` + -Location $Location if ($Ensure -eq 'Present') { if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { @@ -324,14 +305,10 @@ function Get-ItemValue ) # Retrieve the value of the specified property if present. - $Get_WebConfigurationProperty_param = @{ - PSPath = $WebsitePath - Filter = $Filter - Name = $PropertyName - Location = $Location - } - - $value = Get-WebConfigurationProperty @Get_WebConfigurationProperty_param + $value = Get-WebConfigurationProperty -PSPath $WebsitePath ` + -Filter $Filter ` + -Name $PropertyName ` + -Location $Location # Return the value of the property if located. if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { @@ -352,7 +329,7 @@ function Get-ItemValue .PARAMETER Location Optional. Location tag to use for property. - + .PARAMETER PropertyName Required. Name of the property to retrieve. #> @@ -382,13 +359,9 @@ function Get-ItemPropertyType $PropertyName ) - $Get_WebConfiguration_param = @{ - Filter = $Filter - PsPath = $WebsitePath - Location = $Location - } - - $webConfiguration = Get-WebConfiguration @Get_WebConfiguration_param + $webConfiguration = Get-WebConfiguration -Filter $Filter ` + -PsPath $WebsitePath ` + -Location $Location $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } From 623be66df8ef404cd41844c1597a4bc51f240f2b Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Thu, 24 Jan 2019 13:29:54 -0700 Subject: [PATCH 11/16] Update REAMME.md --- README.md | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/README.md b/README.md index dc20924b5..bca89d7d6 100644 --- a/README.md +++ b/README.md @@ -258,16 +258,6 @@ handler processes the full path, contoso/marketing/imageGallery. If the value is Ensures the value of an identified property in the web.config file. -* **WebsitePath**: Path to website location (IIS or WebAdministration format). -* **Filter**: Filter used to locate property to update. -* **PropertyName**: Name of the property to update. -* **Value**: Value of the property to update. -* **Ensure**: Indicates if the property and value should be present or absent. Defaults to 'Present'. { *Present* | Absent } - -### xWebConfigPropertyLocation - -Ensures the value of an identified property in the ApplicationHost.config file under Location section. - * **WebsitePath**: Path to website location (IIS or WebAdministration format). * **Filter**: Filter used to locate property to update. * **PropertyName**: Name of the property to update. From 2951a5c0ef5e56cf7d11930973786dd751dc5653 Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Mon, 28 Jan 2019 10:00:23 -0700 Subject: [PATCH 12/16] Code review modifications --- .../MSFT_xWebConfigProperty.psm1 | 35 +++++++++++++------ README.md | 4 +-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 54815b674..fd4dd95c2 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -71,13 +71,15 @@ function Get-TargetResource Value = $existingValue } - if ( -not($existingValue) ) { + if ( -not($existingValue) ) + { # Property was not found. Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) $result.Ensure = 'Absent' } - else { + else + { # Property was found. Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) } @@ -141,7 +143,8 @@ function Set-TargetResource [string] $Ensure = 'Present' ) - if ($Ensure -eq 'Present') { + if ($Ensure -eq 'Present') + { # Property needs to be updated. Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) @@ -151,9 +154,13 @@ function Set-TargetResource -PropertyName $PropertyName if ($propertyType -match 'Int32|Int64') - { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } + { + $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value + } else - { $setValue = $Value } + { + $setValue = $Value + } Set-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` @@ -162,7 +169,8 @@ function Set-TargetResource -Value $setValue ` -WarningAction "Stop" } - else { + else + { # Property needs to be removed. Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) @@ -238,16 +246,20 @@ function Test-TargetResource -PropertyName $PropertyName ` -Location $Location - if ($Ensure -eq 'Present') { - if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { + if ($Ensure -eq 'Present') + { + if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) + { # Property was not found or didn't have expected value. Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) return $false } } - else { - if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { + else + { + if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) + { # Property was found. Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) @@ -311,7 +323,8 @@ function Get-ItemValue -Location $Location # Return the value of the property if located. - if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) { + if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) + { return $value.Value } return $value diff --git a/README.md b/README.md index bca89d7d6..79daf3f54 100644 --- a/README.md +++ b/README.md @@ -318,8 +318,7 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### Unreleased -<<<<<<< HEAD -* Added new reosurce xWebConfigProperty extening functionality provided by xWebConfigProperty to allow writing of locked sections in ApplicationHost.Config +* Added new parameter 'Location' to **xWebConfigProperty** extending functionality to allow writing of locked sections in ApplicationHost.Config ======= ### 2.4.0.0 @@ -327,7 +326,6 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### 2.3.0.0 ->>>>>>> 0b60a44eea60673f883544ecbf5cd294ecc750a8 * Update appveyor.yml to use the default template. * Added default template file .gitattributes, and added default settings for Visual Studio Code. From bfbb1d9963f9742d77a2e333c693c8a6d5afeb01 Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Sun, 30 Sep 2018 14:01:51 -0600 Subject: [PATCH 13/16] Added xWebConfigPropertyLocation to allow access to locked sections of the ApplicationHost.Config Added documentation to README.MD and samples Updated xWebConfigProperty with location key param Cleaned up tabs Updated unit/integration tests Changed to ASCII MetaFixers update formatting error UnitTestingUpdate1 CodeCov modifications Update REAMME.md Code review modifications --- .../MSFT_xWebConfigProperty.psm1 | 115 ++++++---- .../MSFT_xWebConfigProperty.schema.mof | 1 + Examples/Sample_xWebConfigProperty_Add.ps1 | 1 + Examples/Sample_xWebConfigProperty_Remove.ps1 | 1 + README.md | 13 ++ ...T_xWebConfigProperty.Integration.Tests.ps1 | 1 + .../MSFT_xWebConfigProperty.config.ps1 | 4 + Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 | 206 ++++++++++++++++-- 8 files changed, 289 insertions(+), 53 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 5ec082c9a..fd4dd95c2 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -21,6 +21,9 @@ data LocalizedData .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. #> @@ -40,6 +43,11 @@ function Get-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -47,34 +55,33 @@ function Get-TargetResource ) # Retrieve the value of the existing property if present. Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $existingValue = Get-ItemValue ` - -WebsitePath $WebsitePath ` + $existingValue = Get-ItemValue -WebsitePath $WebsitePath ` -Filter $Filter ` + -Location $Location ` -PropertyName $PropertyName $result = @{ WebsitePath = $WebsitePath Filter = $Filter + Location = $Location PropertyName = $PropertyName Ensure = 'Present' Value = $existingValue } - if (-not($existingValue)) + if ( -not($existingValue) ) { # Property was not found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) $result.Ensure = 'Absent' } else { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) } return $result @@ -90,6 +97,9 @@ function Get-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -114,6 +124,11 @@ function Set-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -131,10 +146,12 @@ function Set-TargetResource if ($Ensure -eq 'Present') { # Property needs to be updated. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath -Filter $Filter -PropertyName $PropertyName + $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath ` + -Filter $Filter ` + -Location $Location ` + -PropertyName $PropertyName if ($propertyType -match 'Int32|Int64') { @@ -145,23 +162,22 @@ function Set-TargetResource $setValue = $Value } - Set-WebConfigurationProperty ` + Set-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` - -PSPath $WebsitePath ` + -Location $Location ` -Name $PropertyName ` -Value $setValue ` - -WarningAction Stop + -WarningAction "Stop" } else { # Property needs to be removed. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) - Clear-WebConfiguration ` - -Filter "$($Filter)/@$($PropertyName)" ` - -PSPath $WebsitePath ` - -WarningAction Stop + Clear-WebConfiguration -PSPath $WebsitePath ` + -Filter "$($Filter)/@$($PropertyName)" ` + -Location $Location ` + -WarningAction "Stop" } } @@ -175,6 +191,9 @@ function Set-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -200,6 +219,11 @@ function Test-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -215,21 +239,19 @@ function Test-TargetResource $Ensure = 'Present' ) # Retrieve the value of the existing property if present. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $targetResource = Get-TargetResource ` - -WebsitePath $WebsitePath ` + $targetResource = Get-TargetResource -WebsitePath $WebsitePath ` -Filter $Filter ` - -PropertyName $PropertyName + -PropertyName $PropertyName ` + -Location $Location if ($Ensure -eq 'Present') { if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { # Property was not found or didn't have expected value. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) return $false } @@ -239,15 +261,13 @@ function Test-TargetResource if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $false } } - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $true } @@ -264,6 +284,9 @@ function Test-TargetResource .PARAMETER Filter Required. Filter used to locate property to retrieve. +.PARAMETER Location + Optional. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to retrieve. #> @@ -283,16 +306,21 @@ function Get-ItemValue [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) + # Retrieve the value of the specified property if present. - $value = Get-WebConfigurationProperty ` - -PSPath $WebsitePath ` + $value = Get-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` - -Name $PropertyName + -Name $PropertyName ` + -Location $Location # Return the value of the property if located. if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) @@ -307,13 +335,16 @@ function Get-ItemValue Gets the current data type of the property. .PARAMETER WebsitePath - Path to website location (IIS or WebAdministration format). + Required. Path to website location (IIS or WebAdministration format). .PARAMETER Filter - Filter used to locate property to retrieve. + Required. Filter used to locate property to retrieve. + +.PARAMETER Location + Optional. Location tag to use for property. .PARAMETER PropertyName - Name of the property to retrieve. + Required. Name of the property to retrieve. #> function Get-ItemPropertyType { @@ -331,15 +362,21 @@ function Get-ItemPropertyType [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) - $webConfiguration = Get-WebConfiguration -Filter $Filter -PsPath $WebsitePath + $webConfiguration = Get-WebConfiguration -Filter $Filter ` + -PsPath $WebsitePath ` + -Location $Location - $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript {$_.Name -eq $propertyName} + $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } return $property.ClrType.Name } diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof index d2a7576a9..1ed4cfa88 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof @@ -4,6 +4,7 @@ class MSFT_xWebConfigProperty : OMI_BaseResource [Key, Description("Path to website location (IIS or WebAdministration format).")] String WebsitePath; [Key, Description("Filter used to locate property to update.")] String Filter; [Key, Description("Name of the property to update.")] String PropertyName; + [Key, Description("Location is used to update locked sections in the root config.")] String Location; [Write, Description("Indicates if the property and value should be present or absent. Defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Write, Description("Value of the property to update.")] String Value; }; diff --git a/Examples/Sample_xWebConfigProperty_Add.ps1 b/Examples/Sample_xWebConfigProperty_Add.ps1 index e8a350583..69717d67e 100644 --- a/Examples/Sample_xWebConfigProperty_Add.ps1 +++ b/Examples/Sample_xWebConfigProperty_Add.ps1 @@ -25,6 +25,7 @@ Configuration Sample_xWebConfigProperty_Add { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' Value = 'false' Ensure = 'Present' diff --git a/Examples/Sample_xWebConfigProperty_Remove.ps1 b/Examples/Sample_xWebConfigProperty_Remove.ps1 index 3f78a9ee7..f5a4fabf6 100644 --- a/Examples/Sample_xWebConfigProperty_Remove.ps1 +++ b/Examples/Sample_xWebConfigProperty_Remove.ps1 @@ -25,6 +25,7 @@ Configuration Sample_xWebConfigProperty_Remove { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' Ensure = 'Absent' } diff --git a/README.md b/README.md index 395cbd13a..9a06fd2c7 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ Ensures the value of an identified property in the web.config file. * **WebsitePath**: Path to website location (IIS or WebAdministration format). * **Filter**: Filter used to locate property to update. * **PropertyName**: Name of the property to update. +* **Location**: Name of the location to update. * **Value**: Value of the property to update. * **Ensure**: Indicates if the property and value should be present or absent. Defaults to 'Present'. { *Present* | Absent } @@ -317,12 +318,24 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### Unreleased +<<<<<<< HEAD +<<<<<<< HEAD +======= +* Added new parameter 'Location' to **xWebConfigProperty** extending functionality to allow writing of locked sections in ApplicationHost.Config +======= +>>>>>>> 2951a5c... Code review modifications ### 2.4.0.0 * Explicitly removed extra hidden files from release package ### 2.3.0.0 +<<<<<<< HEAD +======= +* Added new reosurce xWebConfigProperty extening functionality provided by xWebConfigProperty to allow writing of locked sections in ApplicationHost.Config +>>>>>>> 88e6a09... Added documentation to README.MD and samples +======= +>>>>>>> 2951a5c... Code review modifications * Update appveyor.yml to use the default template. * Added default template file .gitattributes, and added default settings for Visual Studio Code. diff --git a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 index 1cc1e28c3..f1d115da4 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 @@ -47,6 +47,7 @@ try NodeName = 'localhost' WebsitePath = "IIS:\Sites\$($websiteName)" Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' AddValue = $true UpdateValue = $false diff --git a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 index d8b5e2500..8058bd844 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 @@ -8,6 +8,7 @@ Configuration MSFT_xWebConfigProperty_Add { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.AddValue Ensure = 'Present' @@ -25,6 +26,7 @@ Configuration MSFT_xWebConfigProperty_Update { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.UpdateValue Ensure = 'Present' @@ -42,6 +44,7 @@ Configuration MSFT_xWebConfigProperty_Integer { WebsitePath = $Node.WebsitePath Filter = $Node.IntegerFilter + Location = $Node.Location PropertyName = $Node.IntergerPropertyName Value = $Node.IntegerValue Ensure = 'Present' @@ -59,6 +62,7 @@ Configuration MSFT_xWebConfigProperty_Remove { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Ensure = 'Absent' } diff --git a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 index 324968285..e870c88c9 100644 --- a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 +++ b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 @@ -33,27 +33,44 @@ try $script:DSCModuleName = 'xWebAdministration' $script:DSCResourceName = 'MSFT_xWebConfigProperty' - $script:presentParameters = @{ + $script:presentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Value = 'true' Ensure = 'Present' } - - $script:absentParameters = @{ + $script:presentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Value = 'true' + Ensure = 'Present' + } + $script:absentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Ensure = 'Absent' } + $script:absentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Ensure = 'Absent' + } #region Function Get-TargetResource Describe "$($script:DSCResourceName)\Get-TargetResource" { - Context 'Value is absent' { + Context 'Value is absent with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -74,10 +91,36 @@ try } } - Context 'Value is present' { + Context 'Value is absent with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/security/access' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Absent' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be $null + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } + + Context 'Value is present with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -97,6 +140,31 @@ try Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly } } + + Context 'Value is present with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Present' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be 'true' + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } } #endregion Function Get-TargetResource @@ -107,7 +175,19 @@ try return $null } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -119,7 +199,19 @@ try return [System.String]::Empty } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is an empty string at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return [System.String]::Empty + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -131,7 +223,19 @@ try return 'false' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is wrong at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'false' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -143,7 +247,19 @@ try return 'true' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is present and the value is the same at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -155,7 +271,19 @@ try return 'true' } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is absent but value is not null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -167,7 +295,19 @@ try return $null } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is absent and value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -183,7 +323,21 @@ try Mock -CommandName Convert-PropertyValue Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 0 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - String Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'String' } + Mock -CommandName Convert-PropertyValue + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -197,7 +351,21 @@ try Mock -CommandName Convert-PropertyValue -MockWith { return '32' } Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 1 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - Integer Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'Int32' } + Mock -CommandName Convert-PropertyValue -MockWith { return '32' } + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -209,7 +377,17 @@ try Context 'Ensure is absent' { Mock -CommandName Clear-WebConfiguration - Set-TargetResource @script:absentParameters + Set-TargetResource @script:absentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly + } + } + + Context 'Ensure is absent at location' { + Mock -CommandName Clear-WebConfiguration + + Set-TargetResource @script:absentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly From 653f56032bb526b1377e9f2daa70f4912f73bc0b Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Sun, 30 Sep 2018 14:01:51 -0600 Subject: [PATCH 14/16] parent 0b60a44eea60673f883544ecbf5cd294ecc750a8 author GeoffGuynn 1538337711 -0600 committer GeoffGuynn 1548698785 -0700 Updated xWebConfigProperty with location key param Added documentation to README.MD and samples Updated unit/integration tests CodeCov modifications Update README.md Code review modifications --- .../MSFT_xWebConfigProperty.psm1 | 121 ++++++---- .../MSFT_xWebConfigProperty.schema.mof | 1 + Examples/Sample_xWebConfigProperty_Add.ps1 | 1 + Examples/Sample_xWebConfigProperty_Remove.ps1 | 1 + README.md | 6 + ...T_xWebConfigProperty.Integration.Tests.ps1 | 1 + .../MSFT_xWebConfigProperty.config.ps1 | 4 + Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 | 206 ++++++++++++++++-- 8 files changed, 287 insertions(+), 54 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 5ec082c9a..62ab1920f 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -21,6 +21,9 @@ data LocalizedData .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. #> @@ -40,6 +43,11 @@ function Get-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -47,34 +55,33 @@ function Get-TargetResource ) # Retrieve the value of the existing property if present. Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $existingValue = Get-ItemValue ` - -WebsitePath $WebsitePath ` + $existingValue = Get-ItemValue -WebsitePath $WebsitePath ` -Filter $Filter ` + -Location $Location ` -PropertyName $PropertyName $result = @{ WebsitePath = $WebsitePath Filter = $Filter + Location = $Location PropertyName = $PropertyName Ensure = 'Present' Value = $existingValue } - if (-not($existingValue)) + if ( -not($existingValue) ) { # Property was not found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) $result.Ensure = 'Absent' } else { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyFound -f $PropertyName) } return $result @@ -90,6 +97,9 @@ function Get-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -114,6 +124,11 @@ function Set-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -131,13 +146,15 @@ function Set-TargetResource if ($Ensure -eq 'Present') { # Property needs to be updated. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetEditItem -f $PropertyName) - $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath -Filter $Filter -PropertyName $PropertyName + $propertyType = Get-ItemPropertyType -WebsitePath $WebsitePath ` + -Filter $Filter ` + -Location $Location ` + -PropertyName $PropertyName if ($propertyType -match 'Int32|Int64') - { + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } else @@ -145,23 +162,22 @@ function Set-TargetResource $setValue = $Value } - Set-WebConfigurationProperty ` + Set-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` - -PSPath $WebsitePath ` + -Location $Location ` -Name $PropertyName ` -Value $setValue ` - -WarningAction Stop + -WarningAction "Stop" } else { # Property needs to be removed. - Write-Verbose ` - -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseSetTargetRemoveItem -f $PropertyName) - Clear-WebConfiguration ` - -Filter "$($Filter)/@$($PropertyName)" ` - -PSPath $WebsitePath ` - -WarningAction Stop + Clear-WebConfiguration -PSPath $WebsitePath ` + -Filter "$($Filter)/@$($PropertyName)" ` + -Location $Location ` + -WarningAction "Stop" } } @@ -175,6 +191,9 @@ function Set-TargetResource .PARAMETER Filter Required. Filter used to locate property to update. +.PARAMETER Location + Required. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to update. @@ -200,6 +219,11 @@ function Test-TargetResource [string] $Filter, + [Parameter(Mandatory = $true)] + [AllowEmptyString()] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] @@ -215,21 +239,21 @@ function Test-TargetResource $Ensure = 'Present' ) # Retrieve the value of the existing property if present. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath ) + Write-Verbose -Message ($LocalizedData.VerboseTargetCheckingTarget -f $PropertyName, $Filter, $WebsitePath) - $targetResource = Get-TargetResource ` - -WebsitePath $WebsitePath ` + $targetResource = Get-TargetResource -WebsitePath $WebsitePath ` -Filter $Filter ` - -PropertyName $PropertyName + -PropertyName $PropertyName ` + -Location $Location + + $targetResource = Get-TargetResource @Get_TargetResource_param if ($Ensure -eq 'Present') { if ( ($null -eq $targetResource.Value) -or ($targetResource.Value.ToString() -ne $Value) ) { # Property was not found or didn't have expected value. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyNotFound -f $PropertyName) return $false } @@ -239,15 +263,13 @@ function Test-TargetResource if ( ($null -ne $targetResource.Value) -and ($targetResource.Value.ToString().Length -ne 0 ) ) { # Property was found. - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName ) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $false } } - Write-Verbose ` - -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) + Write-Verbose -Message ($LocalizedData.VerboseTargetPropertyWasFound -f $PropertyName) return $true } @@ -264,6 +286,9 @@ function Test-TargetResource .PARAMETER Filter Required. Filter used to locate property to retrieve. +.PARAMETER Location + Optional. Location tag to use for property. + .PARAMETER PropertyName Required. Name of the property to retrieve. #> @@ -283,16 +308,22 @@ function Get-ItemValue [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) + # Retrieve the value of the specified property if present. - $value = Get-WebConfigurationProperty ` - -PSPath $WebsitePath ` + + $value = Get-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` - -Name $PropertyName + -Name $PropertyName ` + -Location $Location # Return the value of the property if located. if ($value -is [Microsoft.IIs.PowerShell.Framework.ConfigurationAttribute]) @@ -307,13 +338,16 @@ function Get-ItemValue Gets the current data type of the property. .PARAMETER WebsitePath - Path to website location (IIS or WebAdministration format). + Required. Path to website location (IIS or WebAdministration format). .PARAMETER Filter - Filter used to locate property to retrieve. + Required. Filter used to locate property to retrieve. + +.PARAMETER Location + Optional. Location tag to use for property. .PARAMETER PropertyName - Name of the property to retrieve. + Required. Name of the property to retrieve. #> function Get-ItemPropertyType { @@ -331,15 +365,22 @@ function Get-ItemPropertyType [string] $Filter, + [Parameter(Mandatory = $false)] + [string] + $Location, + [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string] $PropertyName ) - $webConfiguration = Get-WebConfiguration -Filter $Filter -PsPath $WebsitePath - $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript {$_.Name -eq $propertyName} + $webConfiguration = Get-WebConfiguration -Filter $Filter ` + -PsPath $WebsitePath ` + -Location $Location + + $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } return $property.ClrType.Name } diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof index d2a7576a9..1ed4cfa88 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.schema.mof @@ -4,6 +4,7 @@ class MSFT_xWebConfigProperty : OMI_BaseResource [Key, Description("Path to website location (IIS or WebAdministration format).")] String WebsitePath; [Key, Description("Filter used to locate property to update.")] String Filter; [Key, Description("Name of the property to update.")] String PropertyName; + [Key, Description("Location is used to update locked sections in the root config.")] String Location; [Write, Description("Indicates if the property and value should be present or absent. Defaults to Present."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] String Ensure; [Write, Description("Value of the property to update.")] String Value; }; diff --git a/Examples/Sample_xWebConfigProperty_Add.ps1 b/Examples/Sample_xWebConfigProperty_Add.ps1 index e8a350583..69717d67e 100644 --- a/Examples/Sample_xWebConfigProperty_Add.ps1 +++ b/Examples/Sample_xWebConfigProperty_Add.ps1 @@ -25,6 +25,7 @@ Configuration Sample_xWebConfigProperty_Add { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' Value = 'false' Ensure = 'Present' diff --git a/Examples/Sample_xWebConfigProperty_Remove.ps1 b/Examples/Sample_xWebConfigProperty_Remove.ps1 index 3f78a9ee7..f5a4fabf6 100644 --- a/Examples/Sample_xWebConfigProperty_Remove.ps1 +++ b/Examples/Sample_xWebConfigProperty_Remove.ps1 @@ -25,6 +25,7 @@ Configuration Sample_xWebConfigProperty_Remove { WebsitePath = 'IIS:\Sites\Default Web Site' Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' Ensure = 'Absent' } diff --git a/README.md b/README.md index 395cbd13a..b3322869b 100644 --- a/README.md +++ b/README.md @@ -261,6 +261,7 @@ Ensures the value of an identified property in the web.config file. * **WebsitePath**: Path to website location (IIS or WebAdministration format). * **Filter**: Filter used to locate property to update. * **PropertyName**: Name of the property to update. +* **Location**: Name of the location to update. * **Value**: Value of the property to update. * **Ensure**: Indicates if the property and value should be present or absent. Defaults to 'Present'. { *Present* | Absent } @@ -317,12 +318,17 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### Unreleased +* Added new parameter 'Location' to **xWebConfigProperty** extending functionality to allow writing of locked sections in ApplicationHost.Config +* xWebSite: Full path is used to get list of default documents + ### 2.4.0.0 * Explicitly removed extra hidden files from release package ### 2.3.0.0 +* Added new reosurce xWebConfigProperty extening functionality provided by xWebConfigProperty to allow writing of locked sections in ApplicationHost.Config +* Added new reosurce xWebConfigProperty extening functionality provided by xWebConfigProperty to allow writing of locked sections in ApplicationHost.Config * Update appveyor.yml to use the default template. * Added default template file .gitattributes, and added default settings for Visual Studio Code. diff --git a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 index 1cc1e28c3..f1d115da4 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.Integration.Tests.ps1 @@ -47,6 +47,7 @@ try NodeName = 'localhost' WebsitePath = "IIS:\Sites\$($websiteName)" Filter = 'system.webServer/directoryBrowse' + Location = '' PropertyName = 'enabled' AddValue = $true UpdateValue = $false diff --git a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 index d8b5e2500..8058bd844 100644 --- a/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 +++ b/Tests/Integration/MSFT_xWebConfigProperty.config.ps1 @@ -8,6 +8,7 @@ Configuration MSFT_xWebConfigProperty_Add { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.AddValue Ensure = 'Present' @@ -25,6 +26,7 @@ Configuration MSFT_xWebConfigProperty_Update { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Value = $Node.UpdateValue Ensure = 'Present' @@ -42,6 +44,7 @@ Configuration MSFT_xWebConfigProperty_Integer { WebsitePath = $Node.WebsitePath Filter = $Node.IntegerFilter + Location = $Node.Location PropertyName = $Node.IntergerPropertyName Value = $Node.IntegerValue Ensure = 'Present' @@ -59,6 +62,7 @@ Configuration MSFT_xWebConfigProperty_Remove { WebsitePath = $Node.WebsitePath Filter = $Node.Filter + Location = $Node.Location PropertyName = $Node.PropertyName Ensure = 'Absent' } diff --git a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 index 324968285..e870c88c9 100644 --- a/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 +++ b/Tests/Unit/MSFT_xWebConfigProperty.tests.ps1 @@ -33,27 +33,44 @@ try $script:DSCModuleName = 'xWebAdministration' $script:DSCResourceName = 'MSFT_xWebConfigProperty' - $script:presentParameters = @{ + $script:presentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Value = 'true' Ensure = 'Present' } - - $script:absentParameters = @{ + $script:presentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Value = 'true' + Ensure = 'Present' + } + $script:absentParametersEmptyLocation = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' Ensure = 'Absent' } + $script:absentParametersPresentLocation = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + Ensure = 'Absent' + } #region Function Get-TargetResource Describe "$($script:DSCResourceName)\Get-TargetResource" { - Context 'Value is absent' { + Context 'Value is absent with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -74,10 +91,36 @@ try } } - Context 'Value is present' { + Context 'Value is absent with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/security/access' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Absent' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be $null + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } + + Context 'Value is present with empty location' { $parameters = @{ WebsitePath = 'MACHINE/WEBROOT/APPHOST' Filter = 'system.webServer/advancedLogging/server' + Location = '' PropertyName = 'enabled' } @@ -97,6 +140,31 @@ try Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly } } + + Context 'Value is present with present location' { + $parameters = @{ + WebsitePath = 'MACHINE/WEBROOT/APPHOST' + Filter = 'system.webServer/asp/session' + Location = 'Default Web Site' + PropertyName = 'keepSessionIdSecure' + } + + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Get-TargetResource @parameters + + It 'Should return the correct values' { + $result.Ensure | Should -Be 'Present' + $result.PropertyName | Should -Be 'keepSessionIdSecure' + $result.Value | Should -Be 'true' + } + + It 'Should have called Get-ItemValue the correct amount of times' { + Assert-MockCalled -CommandName Get-ItemValue -Times 1 -Exactly + } + } } #endregion Function Get-TargetResource @@ -107,7 +175,19 @@ try return $null } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -119,7 +199,19 @@ try return [System.String]::Empty } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is an empty string at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return [System.String]::Empty + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -131,7 +223,19 @@ try return 'false' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is present but value is wrong at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'false' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -143,7 +247,19 @@ try return 'true' } - $result = Test-TargetResource @script:presentParameters + $result = Test-TargetResource @script:presentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is present and the value is the same at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:presentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -155,7 +271,19 @@ try return 'true' } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return false' { + $result | Should -Be $false + } + } + + Context 'Ensure is absent but value is not null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return 'true' + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return false' { $result | Should -Be $false @@ -167,7 +295,19 @@ try return $null } - $result = Test-TargetResource @script:absentParameters + $result = Test-TargetResource @script:absentParametersEmptyLocation + + It 'Should return true' { + $result | Should -Be $true + } + } + + Context 'Ensure is absent and value is null at location' { + Mock -CommandName Get-ItemValue -ModuleName $script:DSCResourceName -MockWith { + return $null + } + + $result = Test-TargetResource @script:absentParametersPresentLocation It 'Should return true' { $result | Should -Be $true @@ -183,7 +323,21 @@ try Mock -CommandName Convert-PropertyValue Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 0 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - String Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'String' } + Mock -CommandName Convert-PropertyValue + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -197,7 +351,21 @@ try Mock -CommandName Convert-PropertyValue -MockWith { return '32' } Mock -CommandName Set-WebConfigurationProperty - Set-TargetResource @script:presentParameters + Set-TargetResource @script:presentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly + Assert-MockCalled -CommandName Convert-PropertyValue -Times 1 -Exactly + Assert-MockCalled -CommandName Set-WebConfigurationProperty -Times 1 -Exactly + } + } + + Context 'Ensure is present - Integer Value at location' { + Mock -CommandName Get-ItemPropertyType -MockWith { return 'Int32' } + Mock -CommandName Convert-PropertyValue -MockWith { return '32' } + Mock -CommandName Set-WebConfigurationProperty + + Set-TargetResource @script:presentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Get-ItemPropertyType -Times 1 -Exactly @@ -209,7 +377,17 @@ try Context 'Ensure is absent' { Mock -CommandName Clear-WebConfiguration - Set-TargetResource @script:absentParameters + Set-TargetResource @script:absentParametersEmptyLocation + + It 'Should call the right Mocks' { + Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly + } + } + + Context 'Ensure is absent at location' { + Mock -CommandName Clear-WebConfiguration + + Set-TargetResource @script:absentParametersPresentLocation It 'Should call the right Mocks' { Assert-MockCalled -CommandName Clear-WebConfiguration -Times 1 -Exactly From 9f37f0a75d73f844f819d841eae9e6fd04343db8 Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Mon, 28 Jan 2019 11:33:36 -0700 Subject: [PATCH 15/16] Cleanup --- .../MSFT_xWebConfigProperty.psm1 | 16 ---------------- README.md | 4 ---- 2 files changed, 20 deletions(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index 9a157c5f4..c93278ec7 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -245,11 +245,6 @@ function Test-TargetResource -Filter $Filter ` -PropertyName $PropertyName ` -Location $Location -<<<<<<< HEAD - - $targetResource = Get-TargetResource @Get_TargetResource_param -======= ->>>>>>> 4e039a5669a7f7e3561f7177bb9ea800066d32b4 if ($Ensure -eq 'Present') { @@ -322,10 +317,6 @@ function Get-ItemValue ) # Retrieve the value of the specified property if present. -<<<<<<< HEAD - -======= ->>>>>>> 4e039a5669a7f7e3561f7177bb9ea800066d32b4 $value = Get-WebConfigurationProperty -PSPath $WebsitePath ` -Filter $Filter ` -Name $PropertyName ` @@ -381,18 +372,11 @@ function Get-ItemPropertyType $PropertyName ) -<<<<<<< HEAD - - $webConfiguration = Get-WebConfiguration -Filter $Filter ` - -PsPath $WebsitePath ` - -Location $Location -======= $webConfiguration = Get-WebConfiguration -Filter $Filter ` -PsPath $WebsitePath ` -Location $Location ->>>>>>> 4e039a5669a7f7e3561f7177bb9ea800066d32b4 $property = $webConfiguration.Schema.AttributeSchemas | Where-Object -FilterScript { $_.Name -eq $propertyName } return $property.ClrType.Name diff --git a/README.md b/README.md index 067e92167..b3322869b 100644 --- a/README.md +++ b/README.md @@ -319,11 +319,7 @@ This resource manages the IIS configuration section locking (overrideMode) to co ### Unreleased * Added new parameter 'Location' to **xWebConfigProperty** extending functionality to allow writing of locked sections in ApplicationHost.Config -<<<<<<< HEAD * xWebSite: Full path is used to get list of default documents -======= -======= ->>>>>>> 4e039a5669a7f7e3561f7177bb9ea800066d32b4 ### 2.4.0.0 From 6e1bf9ccf897c8dec30c26a419841a2ef1da50f4 Mon Sep 17 00:00:00 2001 From: GeoffGuynn Date: Mon, 28 Jan 2019 12:20:38 -0700 Subject: [PATCH 16/16] removed a tab... --- .../MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 index c93278ec7..38636d806 100644 --- a/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 +++ b/DSCResources/MSFT_xWebConfigProperty/MSFT_xWebConfigProperty.psm1 @@ -154,7 +154,7 @@ function Set-TargetResource -PropertyName $PropertyName if ($propertyType -match 'Int32|Int64') - { + { $setValue = Convert-PropertyValue -PropertyType $propertyType -InputValue $Value } else