如何使用WMI和Powershell保存对Windows组的更改
使用Powershell,我使用WMI检索Windows组。然后我尝试修改属性并更新对象,但失败了(请参阅下面的错误消息)。怎么了如何使用WMI和Powershell保存对Windows组的更改,powershell,wmi,Powershell,Wmi,使用Powershell,我使用WMI检索Windows组。然后我尝试修改属性并更新对象,但失败了(请参阅下面的错误消息)。怎么了 $group = Get-WmiObject Win32_Group -Filter ("Domain='{0}' and Name='{1}'" -f $env:ComputerName, $groupName) $group.Description = $newDescription $group.Put() 错误: System.Management.Aut
$group = Get-WmiObject Win32_Group -Filter ("Domain='{0}' and Name='{1}'" -f $env:ComputerName, $groupName)
$group.Description = $newDescription
$group.Put()
错误:
System.Management.Automation.MethodInvocationException:使用“0”参数调用“Put”时发生异常:“提供程序无法执行尝试的操作”-->System.Management
.ManagementException:提供程序无法执行尝试的操作,因为Win32_组
对象的说明
属性是只读的。请使用以下选项:
非常感谢,它很有效!我没有想到Description属性可能是只读的,我将重点放在put方法上。
$group = [adsi]"WinNT://$env:COMPUTERNAME/$groupName,group"
$group.Description = $newDescription
$group.SetInfo()