![]() ![]() Type Powershell.exe for the Program/script field.On the Actions tab, select New, and then select Start a program for the Action field.On the Triggers tab, select New, and then select At log on for the Begin the task field.Select Change User or Group, select a local user or group (such as LocalComputer\Users) and then select OK.On the General tab in the Create Task dialog box, type a name (such as Map Network Drives) and description for the task.In Task Scheduler, select Action > Create Task.Copy the script file MapDrives.ps1 to the following location:.Workaround 1: Create a startup itemĪ PowerShell window flashes up when the scheduled task runs. Executing scripts in an elevated security context will prevent mapped drives from being available in the standard user context. If($error.Count -eq 0 -Or $i -eq 0) Īll workarounds should be executed in standard user security context. Write-Host "There was an error mapping $MappedDrive.RemotePath to $MappedDrive.LocalPath" New-SmbMapping -LocalPath $MappedDrive.LocalPath -RemotePath $MappedDrive.RemotePath -Persistent $True $MappedDrives = Get-SmbMapping |where -property Status -Value Unavailable -EQ | select LocalPath,RemotePath The file should be run at a regular but not at an elevated command prompt because it should be run at the same privilege as Windows Explorer: $i=3 PowerShell -File "%SystemDrive%\Scripts\MapDrives.ps1" > "%TEMP%\StartupLog.txt" 2>
0 Comments
Leave a Reply. |