Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用WMI和Powershell保存对Windows组的更改_Powershell_Wmi - Fatal编程技术网

如何使用WMI和Powershell保存对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

使用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.Automation.MethodInvocationException:使用“0”参数调用“Put”时发生异常:“提供程序无法执行尝试的操作”-->System.Management .ManagementException:提供程序无法执行尝试的操作,因为
Win32_组
对象的
说明
属性是只读的。请使用以下选项:


非常感谢,它很有效!我没有想到Description属性可能是只读的,我将重点放在put方法上。
$group = [adsi]"WinNT://$env:COMPUTERNAME/$groupName,group"
$group.Description = $newDescription
$group.SetInfo()