【发布时间】:2022-01-09 17:40:40
【问题描述】:
我将 get-disk 放入一个变量中,当我想用 clear-disk 对其进行管道传输时,我收到 InputObject is null 错误消息。但是,如果我在 Powershell 控制台中单独运行这两行代码,它就可以工作。变量 $USB_Drive 在这两行之外的任何地方都没有使用。知道这可能是什么吗?
这里有两行:
$USB_Drive = Get-Disk | Where-Object BusType -eq USB | Out-GridView -Title 'Select USB Drive' -OutputMode Single
$Results = $USB_Drive | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false -Passthru | New-partition -UseMaximumSize -IsActive -AssignDriveLetter | Format-Volume -FileSystem NTFS
还有错误信息:
ERROR: Clear-Disk : Das Argument für den Parameter "InputObject" kann nicht überprüft werden. Das Argument ist NULL. Geben Sie einen gültigen Wert für das Argument
ERROR: an, und führen Sie den Befehl erneut aus.
ERROR: In C:\Users\jorisbieg\Documents\SAPIEN\PowerShell Studio\Projects\ISODRIVE\ISODRIVE.Run.ps1:196 Zeichen:17
ERROR: + ... USB_Drive | Clear-Disk -RemoveData -RemoveOEM -Confirm:$false -Passth ...
ERROR: + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ERROR: + CategoryInfo : InvalidData: (:) [Clear-Disk], ParameterBindingValidationException
ERROR: + FullyQualifiedErrorId : ParameterArgumentValidationError,Clear-Disk
ERROR:
【问题讨论】:
标签: windows powershell