-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCreateTaskToMaptoLocalFolder.ps1
29 lines (25 loc) · 1.42 KB
/
CreateTaskToMaptoLocalFolder.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# ***************************************************************************
#
# Purpose: This script creates a schedualed task and executes subst during
# logon
#
# ------------- DISCLAIMER -------------------------------------------------
# This script code is provided as is with no guarantee or waranty concerning
# the usability or impact on systems and may be used, distributed, and
# modified in any way provided the parties agree and acknowledge the
# Microsoft or Microsoft Partners have neither accountabilty or
# responsibility for results produced by use of this script.
#
# Microsoft will not provide any support through any means.
# ------------- DISCLAIMER -------------------------------------------------
#
# ***************************************************************************
# register script as scheduled task
$action = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument "/c subst j: ""%ONEDRIVE%\Documents"""
$trigger = New-ScheduledTaskTrigger -AtLogon -RandomDelay (New-TimeSpan -Minutes 1)
$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -Hidden -DontStopIfGoingOnBatteries -Compatibility Win8
$principal = New-ScheduledTaskPrincipal -GroupId "BUILTIN\Users"
$task = New-ScheduledTask -Action $action -Trigger $trigger -Settings $settings -Principal $principal
Register-ScheduledTask -InputObject $task -TaskName "MapJDrive"
#Kick off Schedualed Task
Start-ScheduledTask -TaskName "MapJDrive"