简体   繁体   中英

executing powershell with php

I have following script to get the status of service of remote computer and display it on web page (I have powershell v3.0 installed):

<html !DOCTYPE>
<head>
</head>
<body>

<?php 
    $output = exec('powershell.exe "(Get-Service -computername server_name wudfsvc).Status"');
    echo $output  
?>

</body>
</html>

This works, when I check status of service locally (without -computername parameter) and it works when I run this script in command line. I think, that the problem is, that when I run it in php, it has insufficient rights to get the status of service on the remote computer. I've tried to use "Get-WMIObject -class win32_service" instead of Get-Service, but I only found this example which provides only login without password:

Get-WmiObject Win32_Service -Credential FABRIKAM\administrator Computer Fabrikam

I need to get status of service on remote computer automatically without user interaction. Is it possible?

Thank you!

PHP interacts using the local IIS service account. I usually assign rights to the local IUSR group.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM