【Management】WMF 3.0 beta - PowerShell 3.0 Hyper-V 用コマンドレット

昨日以下の記事を投稿しました。

【Management】Windows Management Framework 3.0 Beta

多くの方は PowerShell 3.0 の機能にワクワクされていると思います。私もそうです。

どんなコマンドレットが使えるかはインストールされている役割や機能に依存するのですが、手元のサーバーにインストールされているモジュールを確認するのであれば以下のように入力してみてください。

PS C:\> Get-Module -ListAvailable

中でも注目したいのが Hyper-V の管理機能です。

これまで、PowerShell から Hyper-V を使用するには以下の方法が用意されていました。

  • WMI の Virtualization プロバイダーを使用する
    ※正直、かなり難しかったです
  • System Center Virtual Machine Managger のコマンドレットを使用する
  • コミュニティ版コマンドレットを使用する
    PowerShell Management Library for Hyper-V

今回の WMF 3.0 には、なんと 162 個もの Hyper-V 用コマンドレットが用意されています。

PS C:\> (Get-Command -Module hyper-v).count 162

以下はその一覧です。

image

PS C:\> Get-Command -Module hyper-v | ft name

Name ---- Add-VMDvdDrive Add-VMFibreChannelHba Add-VMHardDiskDrive Add-VMMigrationNetwork Add-VMNetworkAdapter Add-VMNetworkAdapterAcl Add-VMRemoteFx3dVideoAdapter Add-VMScsiController Add-VMStoragePath Add-VMSwitch Add-VMSwitchExtensionPortFeature Add-VMSwitchExtensionSwitchFeature Checkpoint-VM Compare-VM Complete-VMFailover Connect-VMNetworkAdapter Connect-VMSan Convert-VHD Disable-VMEventing Disable-VMIntegrationService Disable-VMMigration Disable-VMRemoteFXPhysicalVideoAdapter Disable-VMResourceMetering Disable-VMSwitchExtension Disconnect-VMNetworkAdapter Disconnect-VMSan Dismount-VHD Enable-VMEventing Enable-VMIntegrationService Enable-VMMigration Enable-VMRemoteFXPhysicalVideoAdapter Enable-VMResourceMetering Enable-VMSwitchExtension Export-VM Export-VMSnapshot Get-VHD Get-VM Get-VMBios Get-VMComPort Get-VMConnectAccess Get-VMDvdDrive Get-VMFibreChannelHba Get-VMFloppyDiskDrive Get-VMHardDiskDrive Get-VMHost Get-VMHostNumaNode Get-VMHostNumaNodeStatus Get-VMIdeController Get-VMIntegrationService Get-VMMemory Get-VMMigrationNetwork Get-VMNetworkAdapter Get-VMNetworkAdapterAcl Get-VMNetworkAdapterFailoverConfiguration Get-VMNetworkAdapterVlan Get-VMProcessor Get-VMRemoteFx3dVideoAdapter Get-VMRemoteFXPhysicalVideoAdapter Get-VMReplication Get-VMReplicationAuthorizationEntry Get-VMReplicationServer Get-VMResourcePool Get-VMSan Get-VMScsiController Get-VMSnapshot Get-VMStoragePath Get-VMSwitch Get-VMSwitchExtension Get-VMSwitchExtensionPortData Get-VMSwitchExtensionPortFeature Get-VMSwitchExtensionSwitchData Get-VMSwitchExtensionSwitchFeature Get-VMSystemSwitchExtension Get-VMSystemSwitchExtensionPortFeature Get-VMSystemSwitchExtensionSwitchFeature Grant-VMConnectAccess Import-VM Import-VMInitialReplication Measure-VM Measure-VMReplication Measure-VMResourcePool Merge-VHD Mount-VHD Move-VM Move-VMStorage New-VFD New-VHD New-VM New-VMReplicationAuthorizationEntry New-VMResourcePool New-VMSan New-VMSwitch Optimize-VHD Remove-VM Remove-VMDvdDrive Remove-VMFibreChannelHba Remove-VMHardDiskDrive Remove-VMMigrationNetwork Remove-VMNetworkAdapter Remove-VMNetworkAdapterAcl Remove-VMRemoteFx3dVideoAdapter Remove-VMReplication Remove-VMReplicationAuthorizationEntry Remove-VMResourcePool Remove-VMSan Remove-VMSavedState Remove-VMScsiController Remove-VMSnapshot Remove-VMStoragePath Remove-VMSwitch Remove-VMSwitchExtensionPortFeature Remove-VMSwitchExtensionSwitchFeature Rename-VM Rename-VMNetworkAdapter Rename-VMResourcePool Rename-VMSan Rename-VMSnapshot Rename-VMSwitch Repair-VM Reset-VMReplicationStatistics Reset-VMResourceMetering Resize-VHD Restart-VM Restore-VMSnapshot Resume-VM Resume-VMReplication Revoke-VMConnectAccess Save-VM Set-VHD Set-VM Set-VMBios Set-VMComPort Set-VMDvdDrive Set-VMFibreChannelHba Set-VMFloppyDiskDrive Set-VMHardDiskDrive Set-VMHost Set-VMMemory Set-VMMigrationNetwork Set-VMNetworkAdapter Set-VMNetworkAdapterFailoverConfiguration Set-VMNetworkAdapterVlan Set-VMProcessor Set-VMRemoteFx3dVideoAdapter Set-VMReplication Set-VMReplicationAuthorizationEntry Set-VMReplicationServer Set-VMResourcePool Set-VMSan Set-VMSwitch Set-VMSwitchExtensionPortFeature Set-VMSwitchExtensionSwitchFeature Start-VM Start-VMFailover Start-VMInitialReplication Stop-VM Stop-VMFailover Stop-VMInitialReplication Stop-VMReplication Suspend-VM Suspend-VMReplication Test-VHD

すばらしいです。なんか、ものすごい武器を手に入れたような感覚です。

これらとワークフロー機能を組み合わせれば、簡易的なセルフサービス機能なんかも作りこめますね。これについてはおいおいまとめていきたいと思います。