英文:
Wsus and powershell
问题
I would like to know if it is possible to move computers in a group from a csv or txt list ...
the script below machine by machine
Get-WsusServer -Name "contoso" | Get-WsusComputer -NameIncludes "winvm" | Add-WsusComputer -TargetGroupName "Windows Virtual Machines"
thx a lot
Get-WsusServer -Name "contoso" | Get-WsusComputer -NameIncludes (Get-Content D:\pc.txt) | Add-WsusComputer -TargetGroupName "Windows Virtual Machines";
But it does not work.
英文:
I would like to know if it is possible to move computers in a group from a csv or txt list ...
the script below machine by machine
Get-WsusServer -Name "contoso" | Get-WsusComputer -NameIncludes "winvm" | Add-WsusComputer -TargetGroupName "Windows Virtual Machines"
thx a lot
Get-WsusServer -Name "contoso" | Get-WsusComputer -NameIncludes (Get-Content D:\pc.txt) | Add-WsusComputer -TargetGroupName "Windows Virtual Machines"
But it does not work
答案1
得分: 1
当我编写计算机分配脚本时,我也将虚拟机放在不同的计算机组中,而不是物理主机。除此之外,我还进行了更多操作,解析机器名称以确定位置,因为我们在计算机命名架构中包含了地区标识符,但如果只是根据是否为虚拟机,你可以这样做:
Import-Module UpdateServices
$WSUS = Get-WsusServer
$AllGroups = $WSUS.GetComputerTargetGroups()
$VMGroup = $AllGroups.Where({$_.Name -eq 'Windows Virtual Machines'})
$AllComputers = $Groups.Where({$_.Name -eq 'All Computers'}).GetComputerTargets()
$ComputerList = Get-Content D:\pc.txt
$AllComputers.Where({$_.Model -eq 'Virtual Machine'})|ForEach-Object{
$VMGroup.AddComputerTarget($_)
}
或者,如果你想根据文件中的计算机列表进行操作:
$AllComputers.Where({$_.Name -in $ComputerList})|ForEach-Object{
$VMGroup.AddComputerTarget($_)
}
英文:
When I scripted out computer assignments I too put VMs in a different computer group than physical hosts. I did a bit more than that parsing machine names to determine location since we put regional identifiers in our computer naming schema, but just going off if something is a VM you could do this:
Import-Module UpdateServices
$WSUS = Get-WsusServer
$AllGroups = $WSUS.GetComputerTargetGroups()
$VMGroup = $AllGroups.Where({$_.Name -eq 'Windows Virtual Machines'})
$AllComputers = $Groups.Where({$_.Name -eq 'All Computers'}).GetComputerTargets()
$ComputerList = Get-Content D:\pc.txt
$AllComputers.Where({$_.Model -eq 'Virtual Machine'})|ForEach-Object{
$VMGroup.AddComputerTarget($_)
}
Or if you want to go off a list of computers in a file:
$AllComputers.Where({$_.Name -in $ComputerList})|ForEach-Object{
$VMGroup.AddComputerTarget($_)
}
答案2
得分: -1
谢谢你,TheMadTechnician。
事实上,机器按组进行分类,例如:
组A = win10 和组B = W11-21-H2
组C = Win11 22-H2,目标是一次性掌握组C中列表中的若干台机器。
英文:
Thank you so much TheMadTechnician
in fact, the machines are classified by group, for example:
group A= win10 and group B= W11-21-H2
Group C=Win11 22-H2, the goal is to master a certain number of machines in Group C from the list at once
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论