简体   繁体   English

退出VMware vSphere PowerCLI命令提示符?

[英]Exiting VMware vSphere PowerCLI command prompt?

Is there a script to input to exit VMware vSphere PowerCLI command prompt after executing a set of script for example created of VM. 执行一组脚本(例如创建的VM)后,是否有脚本要输入以退出VMware vSphere PowerCLI命令提示符。

MY last line of my .ps1 script is shown below, but the exit does not work, after executing my script, the command prompt is still there, unlike windows command prompt as the exit command works but not in powercli. 我的.ps1脚本的最后一行如下所示,但是退出不起作用,在执行我的脚本后,命令提示符仍然存在,这与Windows命令提示符不同,因为退出命令有效,但在powercli中不起作用。

New-VM -name $vm  -DiskMB 10000 -memoryMB 4000
New-CDDrive -VM $vm -ISOPath  $win7 -StartConnected:$true -Confirm:$false
$scsiController = Get-HardDisk -VM $vm | Select -First 1 | Get-ScsiController
Set-ScsiController -ScsiController $scsiController -Type VirtualLsiLogicSAS -Confirm:$false

Start-VM -vm $vm
Exit

My hunch is that this has more to do with powershell and little to do with PowerCLI. 我的直觉是,这与powershell无关,而与PowerCLI无关。 I'm also guessing that the window closes if you focus it and press 'Enter'. 我还猜测如果将窗口聚焦并按“ Enter”,则窗口将关闭。 I ran into this when executing some powershell scripts long ago, but never came across a decent fix until this evening. 很久以前,我在执行一些Powershell脚本时就遇到了这种情况,但是直到今天晚上才遇到过不错的解决方案。 It seems powershell waits on a Readline() call after executing the script. 在执行脚本后,powershell似乎在等待Readline()调用。

The solution: include the flag -InputFormat None in your call to powershell.exe. 解决方案:在对powershell.exe的调用中包括标志-InputFormat None In your case, I'd include it in the call to the PowerCLI executable, it ought to be passed through. 在您的情况下,我会将其包含在对PowerCLI可执行文件的调用中,应将其传递给它。

Resources: This looks like a known issue from Microsoft's tracker . 资源:这看起来像是Microsoft跟踪器中的一个已知问题 These two questions reference the same fix: 这两个问题引用相同的修复程序:

Please let me know if this works correctly, I'm not on a system with PowerCLI installed currently. 请让我知道这是否可以正常运行,我当前不在安装PowerCLI的系统上。

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM