Unable to execute PowerCLI from PHP Script
Posted: Sat Dec 06, 2014 2:44 am
Hi All,
I am trying to connect to my vsphere server and collect info about VMs my code:
I am getting the following error:
x86 : The term 'x86' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:24
+ -psc C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1
-Com ...
+ ~~~
+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFound
Exception
+ FullyQualifiedErrorId : CommandNotFoundException
VM Info
Get-VM : The term 'Get-VM' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:190
+ ... ite 'VM Info'; Get-VM aaa | Format-List *
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-VM:String) [], CommandNotFo
undException
+ FullyQualifiedErrorId : CommandNotFoundException
Any help on this is great for me.. stuck on a critical project..
Thanks
I am trying to connect to my vsphere server and collect info about VMs my code:
Code: Select all
<?php
$vm = $_POST['search'];
$getvm ="Get-VM $vm | Format-List *";
$stats ="Connect-VIServer x.xxx.xxx.xxx -User xxx -Password xxxx"| out-null; write 'VM Info'; $getvm";
$statscli = "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -ExecutionPolicy Bypass -psc \"C:\\Program Files (x86)\\VMware\\Infrastructure\\vSphere PowerCLI\\vim.psc1\" -Command \"{$stats}\"";
$query = shell_Exec($statscli);
echo ('<pre>');
echo $query;
echo ('<pre>');
?>x86 : The term 'x86' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:1 char:24
+ -psc C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\vim.psc1
-Com ...
+ ~~~
+ CategoryInfo : ObjectNotFound: (x86:String) [], CommandNotFound
Exception
+ FullyQualifiedErrorId : CommandNotFoundException
VM Info
Get-VM : The term 'Get-VM' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:190
+ ... ite 'VM Info'; Get-VM aaa | Format-List *
+ ~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-VM:String) [], CommandNotFo
undException
+ FullyQualifiedErrorId : CommandNotFoundException
Any help on this is great for me.. stuck on a critical project..
Thanks