Skip to content

Get-WsusIISLocalizedNamespacePath returns empty path #20

@ThomasCr

Description

@ThomasCr

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?!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions