Why “net use * /delete” does not work but waits for confirmation in my PowerShell script?

后端 未结 2 1220
忘了有多久
忘了有多久 2020-12-14 06:02

I have a script where I want to disconnect from the mapped drives before I create a new PSDrive.

Otherwise I get this error:

New-PSDrive : Mul

相关标签:
2条回答
  • 2020-12-14 06:15

    With PowerShell 5.1 in Windows 10 you can use:

    Get-SmbMapping | Remove-SmbMapping -Confirm:$false
    
    0 讨论(0)
  • 2020-12-14 06:19

    Try this:

    net use * /delete /y
    

    The /y key makes it select Yes in prompt silently

    0 讨论(0)
提交回复
热议问题