New-PSDrive

Install a new PowerShell drive (ndr, mount) in the current session.

Syntax
      New-PSDrive [-name] string -pSProvider string
         [-root] string [-description string] [-scope string]
            [-credential PSCredential] [-WhatIf] [-confirm] [-UseTransaction] [CommonParameters]

Key
   -name 
       The PowerShell drive name to be added.
       This is not limited to drive letters,any valid string may be used.
       PowerShell drives names are case-sensitive.

   -pSProvider 
       The name of the provider, if omitted you will be prompted.
       e.g. FileSystem, Registry or Certificate.
       type get-psprovider for a list of providers.

   -root string
       The data store location that the PowerShell drive will be mapped to.

       e.g. a network share (\\Server64\files), a local directory (C:\Programs),
       or a registry key (HKLM:\Software\Microsoft).

   -description string
       A short description of the drive.

   -scope 
       A scope for the drive.
       Valid values are "Global", "Local", or "Script", or a number relative
       to the current scope (0 through the number of scopes, where 0 is the
       current scope and 1 is its parent).
       "Local" is the default. For more information, see about_Scopes.

   -credential PSCredential
       A user account that has permission to perform this action.
       The default is the current user.
       a user-name, such as "User01" or "Domain01\User01", or a PSCredential
       object, such as the one retrieved by using the Get-Credential cmdlet.
       If you type a user name, you will be prompted for a password.
       This parameter is not supported by any providers installed with PowerShell.

   -whatIf
       Describe what would happen if you executed the command without
       actually executing the command.

   -confirm
       Prompt for confirmation before executing the command.

   -UseTransaction
       Include the command in the active transaction.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Standard Aliases for New-PSDrive: mount, ndr

New-PSDrive creates a PowerShell drive that is "mapped" to a location in a data store, such as a network drive, a directory on the local computer, or a registry key.

Windows PowerShell drives are known only to PowerShell. They cannot be accessed by Windows Explorer, WMI or CMD tools.

Examples

Install a drive called 'SS64' using the file system provider. The drive will be rooted at "C:\MyDocs":

PS C:\> new-Psdrive -name SS64 -psProvider FileSystem -root C:\MyDocs
DIR SS64:


Install a drive called 'S:' using the file system provider. The drive will be rooted at \\Server64\teams:

PS C:\> new-Psdrive -name S -PsProvider FileSystem -root \\Server64\teams
S:
PS S:\> DIR S:

The parameters are positional, so
PS C:\> New-PSDrive -name M -psprovider FileSystem -root \\Server\Share

is the same as
PS C:\> New-PSDrive M FileSystem \\Server\Share

Map a drive using VBScript, calling .MapNetworkDrive from a Wscript.Network COM object, this method will make a persistent drive map:

PS C:\> $drive = new-object -com wscript.network
PS C:\> $drive.MapNetworkDrive("S:", "\\Server64\teams")

"If the automobile had followed the same development cycle as the computer, a Rolls-Royce would today cost $100, get a million miles per gallon, and explode once a year, killing everyone inside" ~ Robert X. Cringely, InfoWorld

Related:

Get-PSDrive - Get drive information (DriveInfo)
Remove-PSDrive - Remove a provider/drive from its location
Get-Command - Retrieve basic information about a command
Get-Member - Enumerate the properties of an object
Equivalent bash command: mount - Mount a file system


© Copyright SS64.com 1999-2014
Some rights reserved