Proprietà scrivibili di una classe WMI
Do you know how to discover which properties on a WMI class, and therefore a WMI instance, can be modified?
Get-CimClass from the PowerShell 3.0 CIM cmdlets is the answer:
$class = Get-CimClass -ClassName win32_volume
$class.CimClassProperties
The last command returns all of the properties in this format
Notice the first one has a Flag of ReadOnly and the second one has a Qualifier of write. So the question becomes how can you filter on those two items?
If you run something like this:
$class = Get-CimClass -ClassName Win32_Volume
$class.CimClassProperties |
foreach {
if ($psitem | select -ExpandProperty Qualifiers | where Name -eq ‘write’){$psitem}
if (($psitem.Flags -split ‘, ‘) -notcontains ‘Readonly’) {$psitem}
}
You will see that some properties may not be Readonly but also aren’t writable such as:
In that case we need just the writable properties
Get-CimClass -ClassName Win32_Volume |
select -ExpandProperty…
View original post 40 altre parole
Discussione
Non c'è ancora nessun commento.