
PowerShellで
・ネットワークドライブの切断
ができます!

コード
ここでは例として
・Zドライブの切断
をします。

# 切断するドライブ名を指定
$driveName = "Z"
$ws = New-Object -ComObject Wscript.Shell
try
{
# ネットワークドライブの切断を実行
Remove-PSDrive -Name 'Z' -ErrorAction Stop
$ws.popup("切断しました。")
}
catch
{
$ws.popup("エラー : " + $PSItem)
}
実行結果
ネットワークドライブの切断が出来ました。


参考①
ネットワークドライブの割り当てもできます。
詳細は以下の記事をご確認ください。
参考②
上記のコードで使用した以下の詳細は、公式サイトをご確認ください。
●「Remove-PSDrive」コマンドレット