Abr*_*xas 7 windows powershell wsus
我编写了一个脚本,目的是快速管理WSUS进程,我有一些硬编码的东西,但更愿意使用 PowerShell。特别是 Approve-WsusUpdate 的“目标”组。
目前我正在做这样的事情:
#Select Target Group for Update Approval:
$TargetComputerGroups = "All Computers", "Unassigned Computers", "Clients", "Servers", "Test", "View Templates"
$UserPrompt = @"
Please select a Computer Group from the below options:
1) All Computers (Selects all of the below)
2) Unassigned Computers
3) Clients
4) Servers
5) Test
6) View Templates
Enter selection
"@
###Record user selection to varirable
$TargetComputerGroupTemp = Read-Host -Prompt $UserPrompt
###Convert their choice to the correct 0-index array value.
$TargetComputerIndex = $TargetComputerGroupTemp -1
$ComputerTarget = $TargetComputerGroups[$TargetComputerIndex]
Run Code Online (Sandbox Code Playgroud)
是否有“get-targets”命令可以创建一组可用的目标组?这样我就可以删除$TargetComputerGroups
.
另外,我想制作$UserPrompt
一组更好的代码(再次避免手动声明)。我认为做类似的事情'$i for $i in $TargetComputerGroups' write-host 'Press 1 for i'
话虽如此,我对此很陌生,所以我不知道最好的方法(最好将他们的选择映射到该语句中的正确组!)。
Dri*_*104 10
您可以使用 PowerShell 执行此操作,但您还需要在计算机上安装 WSUS 管理控制台。
然后,您可以执行以下操作。
[void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer(“wsus_server”,$False)
$wsus
Run Code Online (Sandbox Code Playgroud)
然后,您可以获得目标群体列表
$wsus.GetComputerTargetGroups()
Run Code Online (Sandbox Code Playgroud)
或选择一个组
$targetgroup = $wsus.GetComputerTargetGroups() | ? {$_.Name -eq "some target name"}
Run Code Online (Sandbox Code Playgroud)
使用 PowerShell 在 WSUS 上执行基本管理任务中有更多信息,但上述信息将为您提供有关组的信息。
归档时间: |
|
查看次数: |
5856 次 |
最近记录: |