Functions/Disconnect-NAS01.ps1
function Disconnect-NAS01 { [CmdletBinding()] param ( [Parameter()] [string] $DriveLetter = "M" ) umount.exe M: -f $AppPath = "powershell.exe" $TaskName = "Launch $AppPath" $Argument = '-NoProfile -command "umount.exe M: -f"' $action = New-ScheduledTaskAction -Execute $AppPath -Argument $Argument $trigger = New-ScheduledTaskTrigger -Once -At (Get-Date) Register-ScheduledTask -Action $action -Trigger $trigger -TaskName $TaskName | Out-Null Start-ScheduledTask -TaskName $TaskName Start-Sleep -s 3 Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false } |