1

I have a PowerShell script that I am trying to run. It opens a CMD window, then closes it. I can briefly see and error. How can I get it to keep the window open so I can see the error? Here is my script I am running.

$ovfTool = "C:\Program Files\VMware\VMware OVF Tool\ovftool.exe"
$user = "root"
$passwd = "MyPassWord"
$SrcESXi = "1.1.1.1"
$DstESXi = "1.1.1.2"
$DstDataStore = "disk-01"
$VM = "Ubuntu"

Start-Process $ovfTool -ArgumentList "--disableVerification --noSSLVerify --powerOn `
 -ds='$DstDataStore' vi://'$user':'$passwd'@'$SrcESXi'/'$VM' vi://'$user':'$passwd'@'$DstESXi'"

I have tried this as well. Adding the -NoNewWindow and -Wait with no luck

$ovfTool = "C:\Program Files\VMware\VMware OVF Tool\ovftool.exe"
$user = "root"
$passwd = "MyPassWord"
$SrcESXi = "1.1.1.1"
$DstESXi = "1.1.1.2"
$DstDataStore = "disk-01"
$VM = "Ubuntu"

Start-Process $ovfTool -ArgumentList "--disableVerification --noSSLVerify --powerOn `
 -ds='$DstDataStore' vi://'$user':'$passwd'@'$SrcESXi'/'$VM' vi://'$user':'$passwd'@'$DstESXi'" -NoNewWindow -Wait
Eric
  • 863
  • 4
  • 17
  • 31
  • 1
    Already answered. It is quicker to search before you ask... https://stackoverflow.com/questions/9244280/how-to-get-powershell-to-keep-a-command-window-open – GrendleM Feb 28 '20 at 16:29
  • 2
    You could potentially use the `-Wait` parameter and provide some way to require user input. Or you could use the `-RedirectStandardError error.txt`, which should contain any errors you normally see at the console. – AdminOfThings Feb 28 '20 at 16:36

0 Answers0