PowerShell 2.0: One Cmdlet at a Time 91 Set-WmiInstance

Continuing the series looking at new cmdlets available in PowerShell 2.0. This time we look at the Set-WmiInstance cmdlet.

What can I do with it?

Set an instance of a WMI class.

Example:

Change the value of MaxLogFileSize within the Win32_WMISetting class from the default of 6556 to 13112.

Set-WmiInstance -Class Win32_WMISetting -Argument @{MaxLogFileSize=13112}

You will notice that the MaxLogFileSize value is updated:

How could I have done this in PowerShell 1.0?

In the above example you could have called the Put method on the object returned in the WMI query.

$wmisetting = Get-WmiObject Win32_WMISetting $wmisetting.MaxLogFileSize = 13112 $wmisetting.Put()

1000 things 1% better