nicolonsky / IntuneDriveMapping

Generate PowerShell scripts to map network drives on Intune managed Windows 10 devices
https://intunedrivemapping.azurewebsites.net/
MIT License
148 stars 17 forks source link

Always On VPN timing issue #24

Closed RefleCs closed 3 years ago

RefleCs commented 3 years ago

When using an Always on VPN the script allready ran before the connection is set-up. I would love to see a check somewhere where it waits for the server to be available before running the script any further.

If there is no connection yet the script wil break with a warning: WARNING: Exception calling "FindOne" with "0" argument(s): "The server is not operational.

DJITS-NL commented 3 years ago

Hi RefleCs,

I have/had the same issue and for that I use a randomdelay of one minute in the script. When opened with PowerShell ISE:

Line 260 $delay = New-TimeSpan -Minutes 1 Line 261 $trigger = New-ScheduledTaskTrigger -AtLogOn -RandomDelay $delay

I would prefer a not random delay but I can't find the proper powershell command to do that.

Hope this helps.

Regards,

DJITS.

nicolonsky commented 3 years ago

Hi guys please see the wiki for a VPN based trigger. This allows to run the task after establishing a VPN connection https://github.com/nicolonsky/IntuneDriveMapping/wiki/Trigger-Script-on-VPN-Connection