Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 694
user3520245 Avatar asked Dec 13 '25 05:12

user3520245


2 Answers

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

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

Working on PS v5.

like image 190
Jelphy Avatar answered Dec 15 '25 18:12

Jelphy


before executing, run the following code:

Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $false
like image 39
IT M Avatar answered Dec 15 '25 19:12

IT M