Skip to content

Offboarding

Nicola Suter edited this page Sep 28, 2020 · 7 revisions

Scheduled task and scripts

If you want to offboard the solution you can replace your DriveMapping.ps1 script in Intune with the following content:

image

# Remove scripts
$scriptSavePath = $(Join-Path -Path $env:ProgramData -ChildPath "intune-drive-mapping-generator")
Remove-Item -Path $scriptSavePath -Recurse -Force

# Remove scheduled task
$schtaskName = "IntuneDriveMapping"
Unregister-ScheduledTask -TaskName $schtaskName -Confirm:$false

Mapped network drives (per user)

Note that the offboarding script above won't delete the mapped network drives, deleting mapped network drives needs to happen under the signed-in user's context. If you want to do this, create an additional script with the following content and deploy it with the "Run this script using the logged on credentials" option:

image

#Remove all locally connected network drives
$psDrives = Get-PSDrive | Where-Object { $_.Provider.Name -eq "FileSystem" -and $_.Root -notin @("$env:SystemDrive\", "D:\") }
foreach ($drive in $psDrives) {
    Remove-SmbMapping -LocalPath "$($drive.Name):" -Force -UpdateProfile
}
Clone this wiki locally