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

Drives will be unmapped if Membership could not retrieved #44

Open IntuneEnterPriseAdmin opened 1 year ago

IntuneEnterPriseAdmin commented 1 year ago

Hello,

if the Script runs (offline, or with no active VPN connection) the Script does not retrieve the GroupMemberships and unmapp all drives with active GroupFilter.

$groupMemberships = Get-ADGroupMembership -UserPrincipalName $(whoami -upn)

this will return nothing

for me i changed it to

if(!$groupMemberships) { Write-Output "No GroupMemberships, exit Script" exit }

so if no GroupMemberships can be retrieved it stops the processing and does not unmapp my Drives.

ps. failure handling in this part is also important

catch {

nothing we can do

  exit

}

Thank you