Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 3.0 » New-PSDrive

New-PSDrive - Powershell 3.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

New-PSDrive

Short description
Creates temporary and persistent mapped network drives.

Syntax
New-PSDrive [-Name] <String> [-PSProvider] <String> [-Root] <String> [-Credential <PSCredential>] [-Description <String
>] [-Persist] [-Scope <String>] [-Confirm] [-WhatIf] [-UseTransaction [<SwitchParameter>]] [<CommonParameters>]





Description
The New-PSDrive cmdlet creates temporary and persistent drives that are "mapped" to or associated with a location in a 
data store, such as a network drive, a directory on the local computer, or a registry key, and persistent Windows mappe
d network drives that are associated with a file system location on a remote computer.


Temporary drives exist only in the current Windows PowerShell session and in sessions that you create in the current se
ssion. They can have any name that is valid in Windows PowerShell and can be mapped to any local or remote resource. Yo
u can use temporary Windows PowerShell drives to access data in the associated data store, just like you would do with 
any mapped network drive. You can change locations into the drive (using "set-location", "cd", or "chdir") and access t
he contents of the drive (using "get-item", "get-childitem", or "dir").


However, because temporary drives are known only to Windows PowerShell, you cannot access them by using File Explorer, 
Windows Management Instrumentation (WMI), Component Object Model (COM), or the Microsoft .NET Framework, or by using to
ols such as Net Use.


New features are added to New-PSDrive in Windows PowerShell 3.0.


-- Mapped network drives: You can use the Persist parameter of New-PSDrive to create Windows mapped network drives. Unl
ike temporary Windows PowerShell drives, Windows mapped network drives are not session-specific; they are saved in Wind
ows and they can be managed by using standard Windows tools, such as File Explorer and Net Use. Mapped network drives m
ust have a drive-letter name and be connected to a remote file system location.


-- External drives: When an external drive is connected to the computer, Windows PowerShell automatically adds a PSDriv
e to the file system that represents the new drive. You do not need to restart Windows PowerShell. Similarly, when an e
xternal drive is disconnected from the computer, Windows PowerShell automatically deletes the PSDrive that represents t
he removed drive.


-- Credentials for UNC Paths: When the value of the Root parameter is a UNC path, such as \\Server\Share, the credentia
l specified in the value of the Credential parameter is used to create the PSDrive. Otherwise, the Credential parameter
 is not effective when creating new file system drives.