Created
November 2, 2019 19:42
-
-
Save CodyMathis123/ee2d34c5cef59c2a8ddc595e398a14b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Remediate = $false | |
$PathShouldBeROOT = Get-ItemProperty -Path "registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Update Services\Server\Setup" -Name ContentDir | Select-Object -ExpandProperty ContentDir | |
$PathShouldBe = Join-Path -Path $PathShouldBeROOT -ChildPath 'WSUSContent' | |
[Void][Reflection.Assembly]::LoadWithPartialName("Microsoft.Web.Administration") | |
$serverManager = New-Object Microsoft.Web.Administration.ServerManager | |
$site = $serverManager.Sites | Where-Object { $_.Name -eq "WSUS Administration" } | |
$rootApp = $site.Applications | Where-Object { $_.Path -eq "/" } | |
$rootVdir = $rootApp.VirtualDirectories | Where-Object { $_.Path -eq "/Content" } | |
$CurrentPath = $rootVdir.PhysicalPath | |
switch ($CurrentPath -eq $PathShouldBe) { | |
$true { | |
$true | |
} | |
$false { | |
switch ($Remediate) { | |
$true { | |
$rootVdir.PhysicalPath = $PathShouldBe | |
$null = $serverManager.CommitChanges() | |
$true | |
} | |
$false { | |
$false | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment