forked from CodyMathis123/CM-Ramblings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSet-WSUSContentPath.ps1
29 lines (26 loc) · 1.03 KB
/
Set-WSUSContentPath.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
$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
}
}
}
}