Python を使用するのは初めての週なので、私の質問がばかげているように聞こえる場合は、事前にお詫びしたいと思います。
基本的に私はこのコードを書きました:
__author__ = 'houssam'
import subprocess
from subprocess import Popen, PIPE
check = subprocess.Popen(["winexe", "--system", "-U","mydomain\\myusername%mypassword", "//computername", "cmd /C c:\\Windows\\System32\\inetsrv\\appcmd list site"],stderr=subprocess.PIPE, stdout=subprocess.PIPE)
(stdout,stderr) = check.communicate()
if check.returncode == 0:
print 'IIS is installed on this system in the location below:'
print stdout
elif check.returncode == 1:
print 'IIS is NOT installed on this system ' and stderr
したがって、基本的に、特定のコンピューター「//computername」の IIS を照会することができ、それは機能します。
しかし、私は20台のコンピュータを持っています。list list = [computer1,computer2,computer3] を作成し、次のような関数を作成します。リスト内の c ごとに、コンピューターの名前を subprocess.check_output 内の唯一の一意のパラメーター「//computername」に置き換えます。 winexe コマンドを呼び出すので、所有しているすべてのコンピューターに対してコマンドを記述する必要はありません。
あなたの助けと提案に感謝します。
ありがとうございました、
ハウサム