I'm trying to get a script that loops through a list of servers, and does an iisreset.
Can someone help me out with this? I'm a little new, and I'm not sure why it fails. It's for windows. I had to use rstrip to get rid of \n. However, it seems to just say it's timing out, and not looping through the servers.
import wmi, getpass
uname = raw_input(r"Username With Domain (Example: prod\a-bob.rick): ")
passwd = getpass.getpass()
file = open(sys.argv, "r")
line = file.readline().rstrip()
x = line
status = raw_input(r"Reset Web Server ")
if str(status).lower() == 'y':
c = wmi.WMI(computer=x, user=uname, password=passwd)
process_id, return_value = c.Win32_Process.Create(CommandLine="iisreset")
for process in c.Win32_Process(ProcessId=process_id):
result = "Success"
result = 'Denied'
result = 'Timeout'
result = 'Fail'