退出 VMware vSphere PowerCLI 命令提示符?
执行一组脚本(例如创建的虚拟机)后,是否需要输入脚本来退出 VMware vSphere PowerCLI 命令提示符。
我的 .ps1 脚本的最后一行如下所示,但退出不起作用,执行我的脚本后,命令提示符仍然存在,与 Windows 命令提示符不同,因为 exit 命令起作用,但在 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
Is there a script to input to exit VMware vSphere PowerCLI command prompt after executing a set of script for example created of VM.
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.
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的直觉是,这与 powershell 更多相关,与 PowerCLI 关系不大。我还猜测,如果您将其聚焦并按“Enter”键,窗口就会关闭。很久以前,我在执行一些 powershell 脚本时遇到了这个问题,但直到今天晚上才找到一个像样的解决方案。执行脚本后,powershell 似乎等待 Readline() 调用。
解决方案:在对 powershell.exe 的调用中包含标志
-InputFormat None
。就您而言,我会将其包含在对 PowerCLI 可执行文件的调用中,它应该被传递。资源:
这看起来像 来自 Microsoft 跟踪器的已知问题。
这两个问题引用了相同的修复:
请告诉我这是否有效正确的是,我当前所在的系统上没有安装 PowerCLI。
祝你好运!
My hunch is that this has more to do with powershell and little to do with PowerCLI. I'm also guessing that the window closes if you focus it and press 'Enter'. I ran into this when executing some powershell scripts long ago, but never came across a decent fix until this evening. It seems powershell waits on a Readline() call after executing the script.
The solution: include the flag
-InputFormat None
in your call to powershell.exe. In your case, I'd include it in the call to the PowerCLI executable, it ought to be passed through.Resources:
This looks like a known issue from Microsoft's tracker.
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.
Good luck!