本文总结了powershell一些零散的知识和WMI.
1)powershell 命令不区分大小写;
2)命令 动词-名次 成对出现。"get-verb"得到所有的动词; "get-command -verb set" 得到所有set-noun命令。
3)PowerShell is an object based scripting language, consequently, it needs .NET Framework for the definitions of the Windows objects. PowerShell works fine with either .Net Framework v 2.0, or v 3.0.
4)"host"命令可以得到powershell的版本等信息
5)"|" 管道符; "$"变量; "$_."对象本身;
6) " `n "换行;" `t "tab键 如:Write-host "Heading `nSub Heading"。"`"是说一个命令被分成了两行。
7) write-host: 输出语句。如:$Now = Get-Date;Write-Host "Today is $Now -enjoy!"
8) WMI全称:Windows Management Instrumentation
9) WQL 全称:WMI Query Language http://hi.baidu.com/escortmnm/blog/item/d6e840133ad0f1ddf6039e6e.html
WMI:
Get-WmiObject
5个有用的Wmiobject参数:
1) -class
2) -namespace
3) -computerName
4) -filter
5) -query
例1:
Get-Wmiobject -class Win32_WmiSetting `
-namespace "root/cimv2" -computerName rtcsebjvista
例2:
Get-WmiObject Win32_LogicalDisk -filter "DeviceID = 'c:' "
例3:
Get-WmiObject -query "select * from Win32_LogicalDisk where DriveType ='3' "