Thursday, 8 September 2011

Get-WmiRegDword.ps1

  1. <# 
  2. .SYNOPSIS 
  3.     This script gets a registry value using WMI. 
  4. .DESCRIPTION 
  5.     This script uses WMI to get then display a resistry value, using  
  6.     the SteRegProv class and the GetDWORDValue static method. 
  7.     This is a re-write of a VB Sample Script 
  8. .NOTES 
  9.     File Name  : Get-WMIRegDword.ps1 
  10.     Author     : Thomas Lee - tfl@psp.co.uk 
  11.     Requires   : PowerShell Version 2.0 
  12. .LINK 
  13.     This script posted to: 
  14.         http://www.pshscripts.blogspot.com 
  15.     MSDN sample posted to: 
  16.         http://msdn.microsoft.com/en-us/library/aa394600%28VS.85%29.aspx 
  17. .EXAMPLE 
  18.     Psh[C:\foo]>Get-WmiRegDword.ps1 
  19. Current History Buffer Size: 50 
  20.      
  21. #> 
  22.  
  23. # Define Constants 
  24. $HKEY_CURRENT_USER =2147483649   
  25. $computer ='.' 
  26.  
  27. # Get Class to call static methods on 
  28. $reg = [WMIClass]"ROOT\DEFAULT:StdRegProv" 
  29.  
  30. #defind key/value to get  
  31. $Key     = "Console" 
  32. $Value   = "HistoryBufferSize" 
  33.  
  34. # Get Value of buffer and display 
  35. $results   = $reg.GetDWORDValue($HKEY_CURRENT_USER, $Key, $value
  36. "Current History Buffer Size: {0}" -f $results.uValue 
Technorati Tags: ,,,

No comments: