Hey guys, I'm having a tiny, mostly cosmetic problem here, would appreciate any help!
First up: I am trying to run a gpupdate on a remote computer with powershell through subprocess.
What happens is when my program gets to the point where it executes the gpupdate function, it goes not responding for a minute or two before returning the expected output.
I assume this is because gpupdate usually takes a bit to run, but is there a way to just tell python to chill until the gpupdate is finished? Or maybe a more efficient way to run the command?
Code block on question:
gpupdate_output = subprocess.run(["powershell", "-Command", rf'cd "C:\Windows\System32\WindowsPowerShell\v1.0\PSTools"; .\Psexec -accepteula \\{pcname} -s -h powershell -command gpupdate /force'],
shell=True, text=True, capture_output=True)
if "Computer Policy update has completed successfully" in gpupdate_output.stdout:
gpupdate_status = True
else:
gpupdate_status = False return gpupdate_status```