Exiting VMware vSphere PowerCLI command prompt?

℡╲_俬逩灬. 提交于 2019-12-13 05:18:49

问题


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

回答1:


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:

  • Powershell and WiX
  • Powershell and MSDeploy

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

Good luck!



来源:https://stackoverflow.com/questions/6824528/exiting-vmware-vsphere-powercli-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!