1
I’m trying to get a result from server B through server A, by Powershell in php. Basically I’m giving the command
PowerShell Get-Printer -ComputerName (Servidor-B) -Name (Impressora) | Format-List
If I run this command locally on the A server I get this result.
Name : teste_1
ComputerName : 10.41.13.95
Type : Local
ShareName :
PortName : 192.168.258.258
DriverName : Generic / Text Only
Location :
Comment :
SeparatorPageFile :
PrintProcessor : winprint
Datatype : RAW
Shared : False
Published : False
PermissionSDDL :
RenderingMode :
KeepPrintedJobs : False
Priority : 1
DefaultJobPriority : 0
StartTime : 0
UntilTime : 0
PrinterStatus : Error
JobCount : 1
DisableBranchOfficeLogging :
BranchOfficeOfflineLogSizeMB :
Until then perfect, but if I go through PHP with Shell_exec through the command;
shell_exec('PowerShell Get-Printer -ComputerName (Servidor-B) -Name (Impressora) | Format-List');
The result is this:
Get-Printer : An error occurred while performing the specified operation. See
the error details for more information.
At line:1 char:1
+ Get-Printer -computername 10.41.13.95 teste_1 | Format-list
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MSFT_Printer:ROOT/StandardCimv2/M
SFT_Printer) [Get-Printer], CimException
+ FullyQualifiedErrorId : HRESULT 0x8007007b,Get-Printer
Some details:
- I’ve run with -Executionpolicy Bypass
- I have already checked which user is running this command through IIS ( Administrator)
- I have tried to execute this command within a . ps1 command within a . bat
Anyway, I’ve run out of ideas, someone can help me ?
Actually, I did an iis on the other server and just called the local command to generate the report that needed, and it worked. Thanks for the tip !!!
– Wilton Gallego