@Ahmed Alshatawi, Thanks for posting in Q&A.
Q1. Will the detection script run daily at 4 PM?
A1. If you’ve scheduled your detection script to run daily at 4 PM, it will only execute at that time if the device is on
Q2. will remediation execute if the device hasn’t been rebooted for 14 days?
A2. Yes, it will.
Q3. What happens if the device is in sleep mode, powered off, or the lid is closed?
A3. The script will not run in sleep mode, powered off, or with the lid closed unless configured to wake up.
Q4.Will the detection and remediation scripts still run in these cases?
A4. Remediation will only trigger if the device is actively checking in with Intune. If it’s asleep or off, the script won’t run until it’s awake. And if the device is in sleep mode or powered off at 4 PM, the tasks will simply be delayed until the device wakes up.
For the script settings, if the script is required to run in the system context, choose Run this script using the logged on credentials No. If the device is 64-bit, please choose Run script in 64-bit PowerShell host Yes.
Hope above information can help you.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.