最近在摸索一種命令方式備份Hyper-V裡的虛擬機器,因為平時備份都是手動關閉VM,然後Export,這樣浪費很多的時間,於是折騰了下,想用命令實現自動化完成VM的備份。
查閱了下資料,看到了一個開源的軟體能夠用此Powershell Management Library裡的命令完成大部分的虛擬機器管理操作,在這裡分享此網站:
http://pshyperv.codeplex.com/
但是在Import 此Module時出現如下錯誤:
Import-Module : There were errors in loading the format data file:
Microsoft.PowerShell, , C:\Program Files\modules\Hyperv\hyperv.
Format.ps1xml : File skipped because of the following validation
exception: File C:\Program Files\modules\Hyperv\hyperv.Format.
ps1xml cannot be loaded. The file C:\Program Files\modules\Hyperv
\hyperv.Format.ps1xml is not digitally signed. The script will not
execute on the system. Please see "get-help about_signing"
for more details...
At line:1 char:14
+ Import-Module <<<< 'C:\Program Files\modules\Hyperv'
+ CategoryInfo : InvalidOperation: (:) [Import-Module],
RuntimeException + FullyQualifiedErrorId : FormatXmlUpate
Exception,Microsoft.PowerShell.Commands.ImportModule
Command
這是powershell的預設安全設定禁用了執行指令碼,要啟用這個功能需要擁有管理員的許可權。,所以用如下命令更改為不受限:
set-ExecutionPolicy Unrestricted
然後Imort-Module "HyperV庫路徑",然後輸入如下命令:
Get-Command -Module HyperV,在PowerShell 命令列下會出現此命令的協助指令
更多精彩內容:http://www.bianceng.cnhttp://www.bianceng.cn/OS/server/