1. Poweshell - What's windows powershell

來源:互聯網
上載者:User

標籤:windows   powershell   

1. What is Windows PowerShell

  • Windows PowerShell is a new Windows command-line shell designed especially for system administrators. The Windows PowerShell includes an interactive prompt and a scripting environment that can be used independently or in combination.


  • Unlike most shells, which accept and return text, Windows PowerShell is built on top of the .NET Framework common language runtime (CLR) and the .NET Framework, and accepts and returns .NET Framework objects


  • 中文解釋

    PowerShell是一個由微軟的提供的全新shell程式,使用了全新的命令提示和指令碼環境。使用PowerShell會給系統管理員帶來什嗎?學習PowerShell的好處又是什嗎?如果你已經有了管理並使用VBScript的經驗,相信你已經知道答案了。Active Directory域現在已經變得更加龐大和複雜,對於那些被束縛在GUI和Microsoft管理主控台上的管理員們,PowerShell將使他們獲得自由!

    不知道各位有沒有登陸到每個server、client修改註冊表的體驗,或者批量處理檔案,大量設定……當你遇到這些問題,會怎麼做?手動設定?還是運行一個指令碼來解決問題?經常使用VBScript的人當然會選擇後者,但是他們會問,為什麼我還要學習PowerShell?

    答案很簡單:PowerShell使用了物件導向方法,基於.Net,這是VBScript所不能提供或者支援的。


    PowerShell是基於對象而不是基於文本

    如果你已經熟練使用cmd.exe和批處理指令碼,那麼我認為你需要一些時間進行概念性的轉變。PowerShell與那些使用VBScript和其他程式設計語言的概念有著根本性的區別,傳統的命令提示字元的輸出是基於文本的,而在PowerShell中則不會。它看起來像文本,但它實際上是一個對象。這就是為什麼我說PowerShell強大的原因,因為一個PowerShell命令(對象)的輸出可以輸入到另一個命令中去,而無需加入額外的代碼。而在傳統的指令碼語言中,如果你想讓一個命令傳遞到另一個命令,就需要額外的代碼來把需要傳遞的命令轉換成第二個命令可以理解的資料與格式。另外牽扯到一個問題,什麼是對象?這個聽起來很熟悉,“在Active Directory域內的一切都是對象。”例如我們的伺服器、電腦、印表機、安全性群組、組策略、使用者等,有了PowerShell,我們就可以很輕鬆的與這些對象進行互動:查看資訊,以及建立、修改或刪除。


    對PowerShell命令進行自訂

    PowerShell命令被稱為的cmdlet。PowerShell內建有超過100個cmdlet。PowerShell的Team Dev利用他們無窮的想象力為這些cmdlet創造了別名,使我們能夠儘可能的利用我們已經習慣的傳統的命令來操作,如:dir、 cd、 del、 copy等等。即使是UNIX的上的老手,也可以便於使用諸如ls、man等命令。為了最大程度上迎合使用者習慣,簡化操作,PowerShell允許使用者為cmdlet建立自己定義的別名,甚至建立自己的cmdlet。


    PowerShell是一個命令列解譯器和指令碼環境

    概括地講就是PowerShell具有兩全其美。DOS僅僅是一個命令列解譯器,輸入命令,然後得到輸出,當然,也可以使用批次檔,但批次檔從本質上只是對輸入的命令這一操作的簡化。在VBScript中,可以利用WSH(Windows指令碼主機),但是並不能在命令提示字元狀態下輸入VBScript代碼。PowerShell與它們都不同卻又相似,它不僅可以輸入命令,而且可以在命令列構建指令碼。PowerShell的一個強大功能是能夠在命令提示字元下建立和測試代碼。


2. PowerShell Version


  • Version 1.0

Version 1.0 was released in 2006 for Windows XP SP2/SP3, Windows Server 2003, and Windows Vista. For Windows Server 2008, it is included as an optional feature.

  • Version 2.0

Version 2.0 is integrated with Windows 7 and Windows Server 2008 R2 and is released for Windows XP with Service Pack 3, Windows Server 2003 with Service Pack 2 and Windows Vista with Service Pack 1.

  • Version 3.0

A new community technology preview 2 (CTP 2) version of Windows Management Framework 3.0 was released by Microsoft in December, 2011


3. Scripts Tools:

  • Windows PowerShell ISE:

    操作步驟:

    Windows PowerShell 整合指令碼環境 (ISE) 是 Windows PowerShell 的主應用程式。啟動 Windows PowerShell ISE  在 Windows PowerShell 控制台 Cmd.exe 或“運行”框中,鍵入 powershell_ise.exe。

  • PowerShell Script Editor:  (PowerGUI.2.3.0.1503)

    Download from here : http://powergui.org/index.jspa

    PowerGUI, a graphical user interface and script editor for Microsoft Windows PowerShell!




4. 參考文獻:

https://msdn.microsoft.com/en-us/library/ee809360.aspx

http://marui.blog.51cto.com/1034148/289823

本文出自 “Ricky's Blog” 部落格,轉載請與作者聯絡!

1. Poweshell - What's windows powershell

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.