Reputation: 18744
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?
Upvotes: 2
Views: 230