Pages

Monday, 5 June 2023

Import TASK scheduler from xml file

 $taskname = "Remove MSTeams (Public version)"

$taskxmlpath = "Path of the xml file"

$taskusername = "SYSTEM"

$taskexists = Get-ScheduledTask -TaskName $taskname -ErrorAction SilentlyContinue

If ($taskexists.TaskName -eq "$taskname") {

Write-host "$taskname -already exists"

}

Else {


Register-ScheduledTask -xml (Get-Content "$taskxmlpath" | Out-String) -TaskName "$taskname" -User $taskusername -Force


write-host "$tasname -registered"

}


No comments:

Post a Comment

test

 # Set the file path you want to check $filePath = "C:\Path\To\Your\File.exe" # Check if file exists if (Test-Path $filePath) {   ...

Search This Blog