PowerShell in Intune - Run Scripts (Create a Scheduled Task) (2/3)

preview_player
Показать описание
In this video, we will run a PowerShell script that creates a Scheduled Task that will run System File Checker every Wednesday at 5am.

We will run the PowerShell script with Intune's built-in Script runner.

Script:
### Create Scheduled Task to run SFC /Scannow each Wednesday 5am
### Author: John Bryntze
### Date: 20th October 2022

## Set Trigger, Task, Settings
$JBNTrigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Wednesday -At 5:00am
$JBNAction = New-ScheduledTaskAction -Execute "SFC" -Argument "/Scannow"
$JBNSetting = New-ScheduledTaskSettingsSet -Compatibility Win8 -AllowStartIfOnBatteries -StartWhenAvailable -DontStopIfGoingOnBatteries

$JBNTask = New-ScheduledTask -Trigger $JBNTrigger -Action $JBNAction -Settings $JBNSetting -Description "System File Checker weekly Wednesday run at 5am"

## Create/Register Scheduled Task
Register-ScheduledTask -TaskPath \JBN\ -TaskName "System File Checker weekly Wednesday run at 5am" -InputObject $JBNTask -User "NT AUTHORITY\SYSTEM"
Рекомендации по теме
Комментарии
Автор

I like always the way you present these tutorials.
NICE JOB!

rashkaViking
Автор

You're getting my favourite teacher in intune winapp 32. Love it !!

adkhan
Автор

I just increased my dings to ALL. I actually watch allot of your stuff as i'm fairly new to Intune, but no one else knows that because I watch allot of videos. I even recommended you to a friend.

lynetteberg
Автор

I noticed that the scheduled task running fine but then, the next run time will be added one hour on top of the scheduled time. I also noticed it could be because the "Synchronize time across zones" inside the "Edit Triggergor" got turned on by default. Any idea how to script it to be off?

woodychiu
Автор

Nice video! Does intune knows it already ran on a system and will that prevent it from running multiple times? In the previous video where you created an app, we could have a way to verify wether the program was already installed.

I simply need to add a line to the hosts file.

I could create an install script as an app in you previous video. Let it do my job and also add an extra value (file, reg key) to verify a succesful run.

Or I could just use a script like this video which is easier. But I don't want the system to run it over and over again.
I can also have my script check if the value already exists before adding it.

Which option would you use?

mr.choice
Автор

I have a powershell script which is need to create a text file on the client system is that possible in intune

soundarya
Автор

Nice one, tested myself but it's not working on my environment. requires elevated rights.

plvfzzi
Автор

-user "NT Authority \system" meant this task ran on a system not user, right ?

dineshchaudhary