![](/img/trans.png)
[英]How to get vmware vm list which has more than 25% of used space of the particular datastore using powershell?
[英]How to check particular VMware VM is not currently running in the task using PowerShell?
我需要檢查特定的VMware VM當前是否在最近的任務中,例如CLone_task,Migrate_VMTask等。並且還要在VM遷移開始之前跳過該VM。
我嘗試了以下代碼:
PS> Get-Task (Get-VM -Name VM1) | Select State Get-Task : Cannot bind parameter 'Status'. Cannot convert the "nalb00cava3" value of type "VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl" to type "VMware.VimAutomation.Sdk.Types.V1.TaskState". At line:1 char:10 + Get-Task (Get-VM -Name nalb00cava3) | Select State + ~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-Task], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,VMware.VimAutomation.ViCore.Cmdlets.Commands.GetTask
這應該可以滿足您的需求,最后一個管道就是您定義特定VM的地方。
Get-Task | ?{$_.ObjectId -match 'VirtualMachine'} | Select @{N='VM';E={(Get-View -Id $_.ObjectId).Name }},State,Description | where {$_.VM -eq "VM1"}
它從Get-Task過濾ObjectId,然后引用ID,確定VM名稱,最后在您定義的VM上過濾。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.