Tuesday, May 1, 2012

[教學] [Hyper-V] PowerShell 自動載入HyperV module

裝完 PowerShell Management Library for Hyper-V 後


每次重新開啟 PowerShell 後 都需要用到Import-Module ,這樣的確有點麻煩!


不過如果可以加在個人profile裡的話,以後重開PowerShell 就會自動載入此module!


步驟如下:
0. 打開PowerShell
1. 檢查是否有profile :>   Test-Path $profile
2. 若有則跳到步驟3
    若沒有則新增一個 :>    New-Item -path $profile -type file -force 


3. 編輯Profile :> notepad.exe $profile
4. 假設你已經裝好 PowerShell Management Library for Hyper-V
則直接在此notepad貼上 Import-Module "C:\Program Files\modules\HyperV\HyperV.psd1"
並存檔離開
5. 接著可以試試看重新打開PowerShell如果沒有出現錯誤訊息的話,就是HyperV Module已經正確載入囉!!


參考資料:
http://technet.microsoft.com/en-us/library/ee692764.aspx



Labels