【发布时间】:2019-03-19 10:01:00
【问题描述】:
我有以下代码:
$output = foreach ($comp in $maschines.name) {
invoke-command -computer comp1 -ScriptBlock {
try
{
get-vm –VMName $using:comp | Select-Object VMId | Get-VHD | Select-Object @{ label = "vm"; expression = {$using:comp} },
path,
VhdType,
VhdFormat,
@{label = "file(gb)"; expression = {($_.FileSize / 1GB) -as [int]} },
@{label = "size(gb)"; expression = {($_.Size / 1GB) -as [int]} }
}
catch
{
Write-Host some error
}
}
}
我不明白
一些错误
但是:
> The operation failed because the file was not found.
> + CategoryInfo : ObjectNotFound: (Microsoft.Hyper...l.VMStorageTask:VMStorageTask) [Ge t-VHD],
> VirtualizationOperationFailedException
> + FullyQualifiedErrorId : ObjectNotFound,Microsoft.Vhd.PowerShell.GetVhdCommand
> + PSComputerName : comp1
我怎样才能得到
一些错误
在缓存块中?
【问题讨论】:
标签: powershell try-catch invoke-command