Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

WSUS Move Computer script not working

$
0
0

I have a script on our Windows 2003 R2 Server for WSUS to move a computer to a specific managed group. Here is the code:

#	Connect to WSUS server

[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer("localhost",$False)

#	Get reference to WSUS Group to which you want to add computer account
$GroupObj = $wsus.GetComputerTargetGroups() | ? {$_.Name -eq "Update - Servers"}

#	Get all environment variables
$a = get-childitem env:

#	Get the computer name from the environment variable list
$serverName = $env:computername

#	Search for the computer account that you want to add
$CompObj = $wsus.SearchComputerTargets($serverName)

#	Add computer to the WSUS Group
foreach($Comp in $COmpObj) {
    $GroupObj.AddComputerTarget($Comp)
}            
When I run it on the WSUS server, I get no errors, but  the machine does not move groups...


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>