Get-WsusIISLocalizedNamespacePath returns empty path
Hi,
I got a lot of error messages with FirstRun.
Get-WebConfigFile : Der Pfad "IIS:\Sites\ClientWebService" kann nicht gefunden werden, da er nicht vorhanden ist.
In C:\Install\Optimize-WsusServer-1.2.1\Optimize-WsusServer.ps1:845 Zeichen:26
+ $wsusWebConfigPath = Get-WebConfigFile -PSPath $iisPath | Select- ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (IIS:\Sites\ClientWebService:String) [Get-WebConfigFile], ItemNotFoundEx
ception
+ FullyQualifiedErrorId : PathNotFound,Microsoft.IIs.PowerShell.Provider.GetWebConfigCommand
So I checked the script step my step and found, that I get no output from the Get-WsusIISLocalizedNamespacePath function:
PS C:\> $iisSitePhysicalPath = Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Update Services\Server\Setup\' -Name "TargetDir"
PS C:\> $iisSitePhysicalPath
C:\Program Files\Update Services\
PS C:\> $iisLocalizedString = Get-Website | Where-Object {$($_.PhysicalPath).StartsWith($iisSitePhysicalPath)} | Select-Object -ExpandProperty Name
PS C:\> $iisLocalizedString
PS C:\> $iisLocalizedNamespacePath = "IIS:\Sites\$iisLocalizedString\ClientWebService"
PS C:\> $iisLocalizedNamespacePath
IIS:\Sites\\ClientWebService
One problem is that Physical Path contains a Environment Variable:
PS C:\> Get-Website
Name ID State Physical Path Bindings
---- -- ----- ------------- --------
Default Web Site 1 Started %SystemDrive%\inetpub\wwwroot http *:80:
https :443: sslFlags=0
This could be fixed with:
$iisLocalizedString = Get-Website |Where-Object -FilterScript {[System.Environment]::ExpandEnvironmentVariables($_.PhysicalPath) -eq [System.Environment]::ExpandEnvironmentVariables($iisSitePhysicalPath)} | Select-Object -ExpandProperty Name
But the problem is also, that the paths dont match!
PS C:\> Write-Host $([System.Environment]::ExpandEnvironmentVariables($(Get-Website | Select-Object -ExpandProperty PhysicalPath)))
C:\inetpub\wwwroot
PS C:\> [System.Environment]::ExpandEnvironmentVariables($iisSitePhysicalPath)
C:\Program Files\Update Services\
So it looks like something is not right?!
Maybe the function should check if the path (IIS:\Sites\XXX\ClientWebService) exists and falls back if not...