B
B
Berkutman2019-08-26 15:55:28
linux
Berkutman, 2019-08-26 15:55:28

How to force powershell linux output output?

Installed on Debian 9 Powershell + PowerCli module (vmware)
The machine is running apache2, php version 7.3
There is such a script govno.ps1

$ipsrv = '10.91.0.100'
$usersrv = 'root'
$paswdsrv = '[email protected]'  
Set-PowerCLIConfiguration -DefaultVIServerMode Multiple -Confirm:$false | Out-Null
Connect-VIServer -Server $ipsrv -User $usersrv -Password $paswdsrv  | Out-Null
Get-VMHost | Select name 
echo "Status:Connect"

On web index.php
<div id="dashbord">
<h1>Dashboard vCenter</h1>
  <p><?php echo Shell_Exec ('pwsh govno.ps1'); ?></p>
</div>

When I run the script on the machine itself, I get the result I need in the terminal, but on the site it only displays echo "Status:Connect", when I try to redirect the output to a text document when executing the script, I get the same result as on the web page.
Get-VMHost | Select name
The script produces this result only in the terminal.
Question: How to force to display what I need on the web, in a text document?
5d63d676aaf79613052844.png
5d63d67c8dffa755157391.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2019-08-26
@yellowmew

for reference :

>Get-Alias echo
Alias           echo -> Write-Output

So I think something like
echo (Get-VMHost).name

A
azarij, 2019-08-26
@azarij

and so?
write-host "$(Get-VMHost | Select name)"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question