Created
October 18, 2017 02:41
-
-
Save marckean/367297954294a46bfebd54a7f332406b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ShedService = New-Object -comobject 'Schedule.Service' | |
$ShedService.Connect() | |
$Task = $ShedService.NewTask(0) | |
$Task.RegistrationInfo.Description = 'M-Drive Mapping' | |
$Task.Settings.Enabled = $true | |
$Task.Settings.AllowDemandStart = $true | |
$trigger = $task.triggers.Create(9) | |
$trigger.Enabled = $true | |
$action = $Task.Actions.Create(0) | |
$action.Path = 'PowerShell.exe' | |
$action.Arguments = '-ExecutionPolicy Unrestricted -File c:\M-Drive.ps1' | |
# $action.WorkingDirectory = '' | |
$taskFolder = $ShedService.GetFolder("\") | |
$taskFolder.RegisterTaskDefinition('M-Drive Mapping', $Task , 6, 'Users', $null, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment