Skip to content

Instantly share code, notes, and snippets.

@CodyMathis123
Created November 2, 2019 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodyMathis123/ee2d34c5cef59c2a8ddc595e398a14b3 to your computer and use it in GitHub Desktop.
Save CodyMathis123/ee2d34c5cef59c2a8ddc595e398a14b3 to your computer and use it in GitHub Desktop.
$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