Create WMI class and add static property or default value

后端 未结 1 1504
猫巷女王i
猫巷女王i 2021-01-27 03:37

I\'m trying to create a WMI class and add a static property, or set the default value of the property

$WMI_Class = New-Object System.Management.ManagementClass(\         


        
1条回答
  •  孤独总比滥情好
    2021-01-27 04:32

    Change your code to :

    $WMI_Class = New-Object System.Management.ManagementClass("root\default", [String]::Empty, $null)
    $WMI_Class.name = "MyCoreClass"
    $WMI_Class.Properties.Add("ver", "Hi, This is sample static value")
    $WMI_Class.Put()
    
    $obj = ([WmiClass] 'root\default:MyCoreClass')
    $ver = $obj.Properties['ver'].Value
    $ver
    

    0 讨论(0)
提交回复
热议问题