Windows PowerShell的12項功能

來源:互聯網
上載者:User

解答PowerShell:PowerShell原來的開發代號是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 ,可以不執行命令就告訴你命令執行結果.如:

PS> stop-service w3* -whatif

4. 擷取副本

PowerShell 可以開始和結束所有命令的副本,可以在指令碼中輕易測試命令並同時儲存.

PS> Start-Transcript -Path c:demodfoshow.txt

PS> Stop-Transcript

5. 從命令列發布Windows對話

因為Windows PowerShell位對象而最佳化,可以向.NET Framework一樣從命令列訪問COM對象,下列命令告訴你的Vista機器發表"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的資料需要多少個700MB的CD.

PS> 11gb/700mb

那麼,需要多少個1000GB的儲存來備份每個320GB,共425個的Vista案頭呢?

PS > (320gb*425)/1000GB

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.