Solved

Managing Mapped Drives

  • 1 December 2021
  • 3 replies
  • 337 views

Userlevel 2
Badge

Considering the shift to remote work, managing mapped drives through group policy isn’t as effective as it would be with the majority of users being on premises. 

I would like to use shift to using Automox worklets to manage mapped network drives, but when I test using PowerShell commands like “New-PSDrive” it runs as the administrator and the drives don’t appear for the end user. 

My current solution is to drop a .cmd file into the startup folder, but this is inelegant. Is there a better way to do this?

icon

Best answer by JohnG-Automox 4 August 2023, 14:20

View original

3 replies

Userlevel 2
Badge

Looks like this was covered in a previous post, but a solution wasn’t found.

Userlevel 5
Badge +1

Could leverage scheduled task running in the user context. 

 

copy-item script.ps1 C:\windows\temp\script.ps1

$TaskStartTime = (Get-Date)
$SchedService = New-Object -ComObject Schedule.Service
$SchedService.Connect()
$Task = $SchedService.NewTask(0)
$Task.RegistrationInfo.Description = 'Description'
$Task.Settings.Enabled = $TaskSchd
$Task.Settings.AllowDemandStart = $true
$Task.Settings.WakeToRun = $true
$trigger = $Task.triggers.Create(1) # https://docs.microsoft.com/en-us/windows/win32/taskschd/triggercollection-create
$trigger.StartBoundary = $TaskStartTime.ToString("yyyy-MM-dd'T'HH:mm:ss")
$trigger.Enabled = $true
$action = $Task.Actions.Create(0)
$action.Path = "c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"
$action.Arguments = '-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File "C:\windows\temp\script.ps1"'
$taskFolder = $SchedService.GetFolder('\')
$taskFolder.RegisterTaskDefinition("Task Name", $Task , 6, 'Users', $null, 4) | out-null

Userlevel 3

Hi @TJ_Coppola,

 

Better late then never here!

 

We’ve just published a new Worklet to our Catalog that will generate a scheduled task to map a network drive during your user’s next log on action. You can check it out here: 

Windows - Configuration - Map Network Drive via Scheduled Task

 

I hope this helps with your request!

 

Have a great day!

Reply