退出VMware vSphere PowerCLI命令提示符? [英] Exiting VMware vSphere PowerCLI command prompt?

查看:520
本文介绍了退出VMware vSphere PowerCLI命令提示符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行一组脚本(例如创建了VM)后,是否有脚本要输入以退出VMware vSphere PowerCLI命令提示符。

Is there a script to input to exit VMware vSphere PowerCLI command prompt after executing a set of script for example created of VM.

我的.ps1脚本的最后一行显示如下,但是退出不工作,执行我的脚本后,命令提示符仍然存在,不像Windows命令提示符作为退出命令工作,但不是在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.

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


推荐答案

我的希望是,这更多地涉及到powerhell和一些与PowerCLI。我也猜到,如果你关注窗口,然后按回车窗口关闭。我跑到这里执行一些powershell脚本很久以前,但从来没有遇到一个体面的解决,直到今天晚上。看来powershell在执行脚本后等待一个Readline()调用。

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.

解决方案:包括 -InputFormat None 在您对powershell.exe的调用。在你的情况下,我将它包含在对PowerCLI可执行文件的调用中,它应该被传递。

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.

资源:
这看起来像一个< a href =https://connect.microsoft.com/PowerShell/feedback/details/572313/powershell-exe-can-hang-if-stdin-is-redirected# =nofollow>来自Microsoft的跟踪器的已知问题。
这两个问题引用相同的修复:

Resources: This looks like a known issue from Microsoft's tracker. These two questions reference the same fix:

  • Powershell and WiX
  • Powershell and MSDeploy

请让我知道如果这个工作正常,我不是在目前安装PowerCLI的系统。

Please let me know if this works correctly, I'm not on a system with PowerCLI installed currently.

祝你好运!

这篇关于退出VMware vSphere PowerCLI命令提示符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆