2

I have some scripts that copy files between a local system and a few shares. These scripts use net use to manage their connections. Since net use doesn't allow mutliple connections I have to be careful to execute these scripts in order so that they don't throw any exception.

Recently I've found that PowerShell's New-PSDrive would create a temporary connection in the context of a PowerShell script:

Creates temporary and persistent drives that are associated with a location in an item data store.

Temporary drives exist only in the current PowerShell session and in sessions that you create in the current session.

Based on this description would it be correct to assume that with PowerShell I could execute multiple scripts at the same time and they all would be able to connect to multiple shares without errors and automatically disconnect when the script ends?

t3chb0t
  • 16,340
  • 13
  • 78
  • 118
  • Why can't you use UNC paths without using `net use`? – Olaf Jan 29 '23 at 14:46
  • @Olaf: I need to use multiple service users and multiple paths and the server is not allowed to keep these connections alive. Only for the copy operation. – t3chb0t Jan 29 '23 at 14:54
  • 1
    I don't see why you need to use `net use` for that but anyway ... `¯\_(ツ)_/¯` – Olaf Jan 29 '23 at 15:23
  • @Olaf: it's the only method I know. There are non-gurus out there too :P – t3chb0t Jan 29 '23 at 16:15

0 Answers0