Stop connection message coming back for Connect-VIServer

I have an IIS machine hosting some PHP that calls a Powershell file. After adding the Powercli snap in in my Powershell file, I makes a connection to vSphere.

When it does it produces some output that I don't want as this gets put on to each php output page.

Name Port User ---- ---- ---- myhostaddress.com 443 mynetwork\reporteruser

I have tried to add variables to the end to stop the feedback

Connect-VIServer -server myhostaddress.com -User $logincred.User -Password $logincred.Password  -WarningAction SilentlyContinue -ErrorAction Continue

but no use.

Is there a way to stop it. Or a clever way to call it so the output is dumped somewhere else please?


  • You can assign the connection to a variable to suppress the output:

    $connection = Connect-VIServer -Server myhostaddress.com  -Credential $cred

    Working on PS v5.