This function doesn't remove drives that were mapped using vbscript. Why?
#
# Function RemoveMappedDrives() -->
#
FUNCTION RemoveMappedDrives{
# ---------------------------------------------------------------------
PROCESS{
$oNet = New-Object -ComObject WScript.Network
$n1 = 0
$cDrive = ""
# Remove only drives mapped F-Z to network.
FOR ( $n1 = 70; $n1 -lt 91; $n1 ++ )
{
# Debug write-host "n1= " $n1
$cDrive = [char]$n1 + ":"
IF( $oNet.EnumNetworkDrives() -contains $cDrive )
{
# Debug write-host "$cDrive= " $cDrive
$oNet = New-Object -ComObject WScript.Network
$oNet.RemoveNetworkDrive( $cDrive, $True )
}
}
Start-Sleep -m 500
} #end process
} #end removemappeddrives.
Thanks,
David.
#
# Function RemoveMappedDrives() -->
#
FUNCTION RemoveMappedDrives{
# ---------------------------------------------------------------------
PROCESS{
$oNet = New-Object -ComObject WScript.Network
$n1 = 0
$cDrive = ""
# Remove only drives mapped F-Z to network.
FOR ( $n1 = 70; $n1 -lt 91; $n1 ++ )
{
# Debug write-host "n1= " $n1
$cDrive = [char]$n1 + ":"
IF( $oNet.EnumNetworkDrives() -contains $cDrive )
{
# Debug write-host "$cDrive= " $cDrive
$oNet = New-Object -ComObject WScript.Network
$oNet.RemoveNetworkDrive( $cDrive, $True )
}
}
Start-Sleep -m 500
} #end process
} #end removemappeddrives.
Thanks,
David.