Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support null value for ServiceAutoStartProvider property of xWebApplication #229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 28 additions & 15 deletions DSCResources/MSFT_xWebApplication/MSFT_xWebApplication.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ data LocalizedData
VerboseSetTargetPreload = Updating Preload for Web application "{0}".
VerboseSetTargetAutostart = Updating AutoStart for Web application "{0}".
VerboseSetTargetIISAutoStartProviders = Updating AutoStartProviders for IIS.
VerboseSetTargetWebApplicationAutoStartProviders = Updating AutoStartProviders for Web application "{0}".
VerboseSetTargetWebApplicationAutoStartProviders = Updating AutoStartProviders for Web application "{0}".
VerboseSetTargetWebApplicationClearAutoStartProviders = Removing AutoStartProviders for Web application "{0}".
VerboseTestTargetFalseAbsent = Web application "{0}" is absent and should not absent.
VerboseTestTargetFalsePresent = Web application $Name should be absent and is not absent.
VerboseTestTargetFalsePhysicalPath = Physical path for web application "{0}" does not match desired state.
Expand Down Expand Up @@ -229,22 +230,34 @@ function Set-TargetResource
if ($PSBoundParameters.ContainsKey('ServiceAutoStartProvider') -and `
$webApplication.serviceAutoStartProvider -ne $ServiceAutoStartProvider)
{
if (-not (Confirm-UniqueServiceAutoStartProviders `
-ServiceAutoStartProvider $ServiceAutoStartProvider `
-ApplicationType $ApplicationType))
if ($ServiceAutoStartProvider -eq $null)
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetIISAutoStartProviders)
Add-WebConfiguration `
-filter /system.applicationHost/serviceAutoStartProviders `
-Value @{name=$ServiceAutoStartProvider; type=$ApplicationType} `
-ErrorAction Stop
Write-Verbose -Message `
($LocalizedData.VerboseSetTargetWebApplicationClearAutoStartProviders `
-f $Name)
Clear-ItemProperty -Path "IIS:\Sites\$Website\$Name" `
-Name serviceAutoStartProvider `
-ErrorAction Stop
}
else
{
if (-not (Confirm-UniqueServiceAutoStartProviders `
-ServiceAutoStartProvider $ServiceAutoStartProvider `
-ApplicationType $ApplicationType))
{
Write-Verbose -Message ($LocalizedData.VerboseSetTargetIISAutoStartProviders)
Add-WebConfiguration `
-filter /system.applicationHost/serviceAutoStartProviders `
-Value @{name=$ServiceAutoStartProvider; type=$ApplicationType} `
-ErrorAction Stop
}
Write-Verbose -Message `
($LocalizedData.VerboseSetTargetWebApplicationAutoStartProviders -f $Name)
Set-ItemProperty -Path "IIS:\Sites\$Website\$Name" `
-Name serviceAutoStartProvider `
-Value $ServiceAutoStartProvider `
-ErrorAction Stop
}
Write-Verbose -Message `
($LocalizedData.VerboseSetTargetWebApplicationAutoStartProviders -f $Name)
Set-ItemProperty -Path "IIS:\Sites\$Website\$Name" `
-Name serviceAutoStartProvider `
-Value $ServiceAutoStartProvider `
-ErrorAction Stop
}
}

Expand Down