For some actions in WMI you need to enable privileges , for example for the SetDateTime method of win32_operatingsystem,
and how you can use the GUI again to edit settings, and change Classes , and also see posible values of properties also with the searcher you can do the same as we did see in (" PowerShell : WMI Support in RC2 (Series part 2) "," PowerShell : WMI Support in RC2 (Series part 1) ","
[WmiSearcher]$roq | opg
as I did get a question by G/\/\E on the second part of this series, I did this quick post about this *Remark* I did not see the blog item he did make about this, about this when I started this
to see about that strange timeformat see second example, More information about calling methods in next post
PoSH>$win32_Operatingsystem = gwmi win32_Operatingsystem
PoSH>$win32_Operatingsystem.SetDateTime("20061010234615.000000+120")
Exception calling "SetDateTime" : "Access denied "
At line:1 char:35
+ $win32_Operatingsystem.SetDateTime( <<<< "20061010234615.000000+120")
PoSH>$win32_Operatingsystem.psbase.ScopeIsConnected Options Path
----------- ------- ----
True System.Management.ConnectionOptions \\localhost\root\cimv2PoSH>$win32_Operatingsystem.psbase.Scope.options
Locale :
Username :
Password :
Authority :
Impersonation : Impersonate
Authentication : Unchanged
EnablePrivileges : False
Context : {}
Timeout : 10675199.02:48:05.4775807
PoSH>$win32_Operatingsystem.psbase.Scope.options.EnablePrivileges = $true
PoSH>$win32_Operatingsystem.SetDateTime("20061010234615.000000+120")__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
Here you can see that you can also use the out-PropertyGrid to Edit and test those Settings as I showed in former posts about queries (Change properties and query will be automatically changed), *Note* you need to change to WmiClass eg to win32_share and back Note the changing of paths in the GUI, to reconnect and enable the privileges, note that you have a complete WMI browsel like this,
also I show the use of a added utility property added to a WMI class in RC2 to get a WMI dateTime, a bit more about methods in next post
PoSH>$win32_Operatingsystem = gwmi win32_Operatingsystem
PoSH>$win32_Operatingsystem.ConvertfromDateTime("10/10/2006 23:26:15")
20061010232615.000000+120PoSH>$win32_Operatingsystem.SetDateTime("20061010232615.000000+120")
Exception calling "SetDateTime" : "Access denied "
At line:1 char:35
+ $win32_Operatingsystem.SetDateTime( <<<< "20061010232615.000000+120")
PoSH>$win32_Operatingsystem | opg
CancelPoSH>$win32_Operatingsystem | opg
Cancel
PoSH>$win32_Operatingsystem.SetDateTime("20061010232615.000000+120")__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 1
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
ReturnValue : 0
Enjoy,
Greetings, /\/\o\/\/
Tags : Monad PowerShell
October 2005 November 2005 December 2005 January 2006 February 2006 March 2006 April 2006 May 2006 June 2006 July 2006 August 2006 September 2006 October 2006 November 2006 December 2006