StdRegProv
来源:互联网 发布:人工智能猜密码 编辑:程序博客网 时间:2024/05/16 16:07
The StdRegProv class contains methods that manipulate system registry keys and values.
To check all the methods that are available from the class StdRegProv:
$Reg = [WMIClass]"root\default:stdRegProv"
$Reg | Get-Member
Registry keys are classified into six different categories (hives) identified by the following unique registry hive constants. You need these unique numbers to access the right keys and their values.
HiveDecimal ValueHexidecimal ValueHKEY_CLASSES_ROOT21474836480x80000000HKEY_CURRENT_USER21474836490x80000001HKEY_LOCAL_MACHINE21474836500x80000002HKEY_USERS21474836510x80000003HKEY_CURRENT_CONFIG21474836530x80000005HKEY_DYN_DATA21474836540x80000006
To get a list of service names listed as subkeys under the SYSTEM\CurrentControlSet\Services key in the HKEY LOCAL MACHINE registry hive:
$Reg = [WMIClass]"root\default:stdRegProv"
$HKEY_LOCAL_MACHINE = 2147483650 $strKeyPath = "SYSTEM\CurrentControlSet\Services"
$services=$Reg.EnumKey($HKEY_LOCAL_MACHINE,$strKeyPath)
$services.sNames
To query certain information about SQL Server, such as what network libraries are installed and whether they are enabled(value=1):
$Reg = [WMIClass]"root\default:stdRegProv"
$HKEY_LOCAL_MACHINE = 2147483650
$strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\SuperSocketNetLib"
$netlib=$Reg.EnumKey($HKEY_LOCAL_MACHINE,$strKeyPath)
$netlib.sNames | Foreach-Object { $_ + "=" +
$Reg.GetDWORDValue($HKEY_LOCAL_MACHINE,$strKeyPath+'\'+ $_,"Enabled").uValue}
To obtain all the values under the Named Pipes registry key:
$Reg = [WMIClass]"root\default:stdRegProv"
$HKEY_LOCAL_MACHINE = 2147483650
$strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Np"
$namedpipe=$Reg.EnumValues($HKEY_LOCAL_MACHINE,$strKeyPath)
$namedpipe.sNames
The name of the named pipe and the TCP/IP port number are of type REG SZ, which is a string. You can obtain them with the GetStringValue method using the following commands:
$Reg = [WMIClass]"root\default:stdRegProv"
$HKEY_LOCAL_MACHINE = 2147483650
$strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Np"
$pipeName=$reg.GetStringValue($HKEY_LOCAL_MACHINE,$strKeyPath,"Pipename").svalue
$pipeName
$strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Tcp\IPAll"
$TcpPort=$reg.GetStringValue($HKEY_LOCAL_MACHINE,$strKeyPath,"TcpPort").svalue
$TcpPort
To create a new value name and value data under SOFTWARE\Microsoft\MSSQLServer\MSSQLServer\SuperSocketNetLib\Np in the registry:
$HKEY_LOCAL_MACHINE = 2147483650
$Reg = [WMIClass]"root\default:stdRegProv"
$strKeyPath = "SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQLServer\SuperSocketNetLib\Np"
$strValueName = "TestValueName"
$strValue = "TestValue"
$Reg.CreateKey($HKEY_LOCAL_MACHINE,$strKeyPath)
$Reg.SetStringValue($HKEY_LOCAL_MACHINE,$strKeyPath,$strValueName,$strValue)
$Reg.GetStringValue($HKEY_LOCAL_MACHINE,$strKeyPath,"TestValueName").svalue
To delete this key, use the DeleteValue method:
$Reg.DeleteValue($HKEY_LOCAL_MACHINE, $strKeyPath, "TestValueName")
- StdRegProv
- StdRegProv类所属方法的使用(之一)
- WMI 中 root/DEFAULT/StdRegProv 的使用例程
- StdRegProv类所属方法的使用(之二)
- StdRegProv类所属方法的使用(之三)
- StdRegProv类所属方法的使用(之四)
- StdRegProv类所属方法的使用(之五)
- StdRegProv类所属方法的使用(之六)
- XFree86、X11、X-window、窗口经管器、GNOME、KDE的关系
- try-finally中的返回值
- VirtualBox中HOST-ONLY模式下共享上网
- neon指令进行yuv420到rgb24转换效率
- Google Analytics重大更新,新增企业社交营销ROI分析功能
- StdRegProv
- S3C2440 uboot移植系列教程
- QQ2012[QQ圈子]功能试用:按照真实生活将好友分圈
- MD5加密
- GET_GLOBALS_FROM_SLVC_FULLSCR
- WTL学习指南
- javaScript禁止粘贴复制
- MFC tab控件
- jquery取<input>的readOnly属性,O要大写