- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-08-2024 10:09 AM
anyone know if is possible to run script on Cortex XDR and force windows update installation on machines?
08-08-2024 10:51 AM
Hi @tlmarques, thanks for reaching us using the Live Community.
It could be possible by calling the required powershell commands from the Python code supported by the agent.
Take a look and use this example I have created to automatically lock the screen after 10 minutes of inactivity:
import subprocess
# Set the auto screen lock timeout comand, the value in seconds is defined at "-Value"
result = subprocess.run(['powershell.exe', '-command','New-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" -Name "InactivityTimeoutSecs" -Value 10 -PropertyType DWord -Force'], shell=True, capture_output=True, text=True)
# Check if the PowerShell command ran successfully and returns a message
if result.returncode == 0:
print("Auto screen lock timeout set successfully.")
else:
print("Error setting auto screen lock timeout:")
print(result.stderr)
If this post answers your question, please mark it as the solution.
08-08-2024 10:51 AM
Hi @tlmarques, thanks for reaching us using the Live Community.
It could be possible by calling the required powershell commands from the Python code supported by the agent.
Take a look and use this example I have created to automatically lock the screen after 10 minutes of inactivity:
import subprocess
# Set the auto screen lock timeout comand, the value in seconds is defined at "-Value"
result = subprocess.run(['powershell.exe', '-command','New-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System" -Name "InactivityTimeoutSecs" -Value 10 -PropertyType DWord -Force'], shell=True, capture_output=True, text=True)
# Check if the PowerShell command ran successfully and returns a message
if result.returncode == 0:
print("Auto screen lock timeout set successfully.")
else:
print("Error setting auto screen lock timeout:")
print(result.stderr)
If this post answers your question, please mark it as the solution.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!