Windows PowerShell 1.0已經(jīng)發(fā)布,微軟windowsVistablog上,開發(fā)人員列舉了Windows Vista中Windows PowerShell所提供的12項酷酷的功能:
解答PowerShell:PowerShell原來的開發(fā)代號是Monad,原計劃是用以替代Windows中的命令行工具,但是后來微軟說它只是技術上的擴充。使用PowerShell,管理員可以做任何在圖形界面下所做的事情。Windows PowerShell 1.0可以運行在Windows xp SP2、Windows Server 2003和Windows Vista上。
1. 內置Cmdlets (即"commandlets")
Windows PowerShell中的所有Cmdlets都允許這樣的動名詞:get-service, get-PRocess, stop-service, get-wmiobject.
2. 強大的通配符和操作對象
要得到以w開頭的服務及其依賴服務只要輸入:
PS> get-service w* | format-list DisplayName, DependentServices
3. 在犯錯誤前測試命令
Windows PowerShell 有意向獨特的功能:Whatif ,可以不執(zhí)行命令就告訴你命令執(zhí)行結果.如:
PS> stop-service w3* -whatif
4. 獲取副本
PowerShell 可以開始和結束所有命令的副本,可以在腳本中輕易測試命令并同時保存.
PS> Start-Transcript -Path c:demodfoshow.txt
PS> Stop-Transcript
5. 從命令行發(fā)布Windows對話
因為Windows PowerShell位對象而優(yōu)化,可以向.NET Framework一樣從命令行訪問COM對象,下列命令告訴你的Vista機器發(fā)表"Windows Vista and PowerShell"字串.
PS> $spVoice = new-object -com "SAPI.spvoice"
PS> $spVoice.Speak("Windows Vista and PowerShell")
6. 使用Windows PowerShell訪問諸如Windows Media Player 11等的應用程序
PS> $band = "The Posies"
PS> $player = New-object -com wmplayer.ocx
PS> $playlist = $player.mediacollection.getbyauthor($band)
PS> $player.openPlayer($playlist.item(0).sourceurl)
7. Windows PowerShell作為命令行存儲計算器
PowerShell可以完成基本的計算工作
PS> 2*2
不過,Windows PowerShell也可以快速解決存儲問題,例如,備份11GB的數(shù)據(jù)需要多少個700MB的CD.
PS> 11gb/700mb
那么,需要多少個1000GB的存儲來備份每個320GB,共425個的Vista桌面呢?
PS > (320gb*425)/1000GB
8. PowerShell 用作日歷計算
計算多少天到新年:
PS> ([DateTime]"1/1/2007" -[datetime]::now).days
9. 返回機器上某種類型文件的數(shù)量
Windows Vista有許多類型的事件記錄和組策略文件等.下列命令是返回當前目錄及其子目錄中VBScript, Bat 和 PowerShell 腳本的數(shù)量:
PS> dir -include *.vbs, *.ps1, *.bat -recurse | group-object extension -noelement
10. 從命令行收集Windows System Assessment Tool數(shù)據(jù)
PS> get-wmiobject win32_winsat | format-table __SERVER, *SCORE -autosize
PS> get-wmiobject win32_winsat | select *score | out-chart -Title "System Assessment Scores by PowerGadgets"
11. 配置UAC(User Account Control)
PS> set-itemproperty -path HKLM:SOFTWAREMICROSOFTWINDOWSCurrentVersionPoliciesSystem -name ConsentPromptBehaviorAdmin -value 0
12. 管理BitLocker
PS > $drives = get-wmiobject -namespace rootCIMv2SecurityMicrosoftVolumeEncryption -class Win32_EncryptableVolume
PS> $drives | format-table DriveLetter, PersistentVolumeID -autosize
PS> $BitLockDrive = $drives[0]
PS> $BitLockDrive.GetProtectionStatus()
PS> $BitLockDrive.DisableKeyProtectors()
PS> $BitLockDrive.EnableKeyProtectors()
|
新聞熱點
疑難解答
圖片精選