Gets the Windows PowerShell drives in the current session. (Get-PSDrive)

   

# NAME
Get-PSDrive

# SYNOPSIS
Gets the Windows PowerShell drives in the current session.

# SYNTAX
Get-PSDrive [-LiteralName] <string[]> [-PSProvider <string[]>] [-Scope <string>] [-UseTransaction] [<CommonParameters>]

Get-PSDrive [[-Name] <string[]>] [-PSProvider <string[]>] [-Scope <string>] [-UseTransaction] [<CommonParameters>]

# DESCRIPTION
The Get-PSDrive cmdlet gets the Windows PowerShell drives in the current session. You can get a particular drive or all drives in the console.

Get-PSDrive gets the following drives:

-- Windows logical drives on the computer, including drives mapped to network shares.

-- Drives exposed by Windows PowerShell providers (such as the Certificate:, Function:, and Alias: drives) and the HKLM: and HKCU: drives that are exposed by the Windows PowerShell Registry provider.

-- Drives that you create by using New-PSDrive.

Get-PSDrive does not get Windows mapped drives that are added or created after the Windows PowerShell console is opened.

# PARAMETERS
-LiteralName <string[]>
Specifies the name of the Windows PowerShell drive.

The value of LiteralName is used exactly as it is typed. No characters are interpreted as wildcards. If the name includes escape characters, enclose it in single quotation marks. Single quotation marks tell Windows PowerShell not to interpret any characters as escape sequences.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Name <string[]>
Gets only the specified drives. Type the drive name or letter without a colon (:).

Required? false
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-PSProvider <string[]>
Gets only the drives supported by the specified Windows PowerShell provider. Type the name of a provider, such as FileSystem, Registry, or Certificate.

Required? false
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Scope <string>
Gets only the Windows PowerShell drives in the specified scope. 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.

Required? false
Position? named
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-UseTransaction [<SwitchParameter>]
Includes the command in the active transaction. This parameter is valid only when a transaction is in progress. For more information, see about_Transactions.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
None
You cannot pipe objects to Get-PSDrive.

# OUTPUTS
System.Management.Automation.PSDriveInfo
Get-PSDrive returns objects that represent the Windows PowerShell drives in the session.

# NOTES

The Get-PSDrive cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type "get-psprovider". For more information, see about_Providers.

# EXAMPLE 1

C:\PS>get-psdrive

Name Provider Root
---- -------- ----
Alias Alias
C FileSystem C:\
cert Certificate \
D FileSystem D:\
Env Environment
Function Function
HKCU Registry HKEY_CURRENT_USER
HKLM Registry HKEY_LOCAL_MACHINE
Variable Variable
X FileSystem X:\

# Description
-----------
This command gets the Windows PowerShell drives in the current session.

The output shows the hard drive (C:) and CD-ROM drive (D:) on the computer, the drives exposed by the Windows PowerShell providers (Alias:, Cert:, Env:, Function:, HKCU:, HKLM:, and Variable:), and a drive mapped to a network share (X:).

# EXAMPLE 2

C:\PS>get-psdrive d

Name Provider Root
---- -------- ----
D FileSystem D:\

# Description
-----------
This command displays the D: drive on the computer. Note that the drive letter is not followed by a colon.

# EXAMPLE 3

C:\PS>get-psdrive -psprovider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

# Description
-----------
This command displays all of the drives that are supported by the Windows PowerShell FileSystem provider. This includes fixed drives, logical partitions, mapped network drives, and drives that you create by using New-PSDrive that are mapped to the file system drives.

This example shows that drives created by New-PSDrive have the name of the mapped location in the value of the Root property. Windows drives just have the root of the drive letter.

# EXAMPLE 4

C:\PS>if (!(get-psdrive X)) {
new-psdrive -name X -psprovider Registry -root HKLM:\Network
}
else { write-host "The X: drive is already in use." }

# Description
-----------
This command checks to see whether the X drive is already in use as the Windows PowerShell drive name. If it is not, the command uses the New-PSDrive cmdlet to create a Windows PowerShell drive that is mapped to the HKLM:\Network registry key.

# EXAMPLE 5

C:\PS>get-psdrive -provider filesystem

C:\PS> get-psdrive -provider filesystem

Name Provider Root
---- -------- ----
C FileSystem C:\
D FileSystem D:\
X FileSystem X:\
Y FileSystem \\Server01\Public
Z FileSystem C:\Windows\System32

C:\PS> net use
New connections will be remembered.

Status Local Remote Network
-------------------------------------------------------------------------------
X: \\Server01\Public Microsoft Windows Network

C:\PS> [System.IO.DriveInfo]::getdrives()

Name : C:\
DriveType : Fixed
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 39831498752
TotalFreeSpace : 39831498752
TotalSize : 79900368896
RootDirectory : C:\
VolumeLabel :
Name : D:\
DriveType : CDRom
DriveFormat :
IsReady : False
AvailableFreeSpace :
TotalFreeSpace :
TotalSize :
RootDirectory : D:\
VolumeLabel :
Name : X:\
DriveType : Network
DriveFormat : NTFS
IsReady : True
AvailableFreeSpace : 36340559872
TotalFreeSpace : 36340559872
TotalSize : 36413280256
RootDirectory : X:\
VolumeLabel : D_Drive

C:\PS> get-wmiobject win32_logicaldisk

DeviceID : C:
DriveType : 3
ProviderName :
FreeSpace : 39831252992
Size : 79900368896
VolumeName :
DeviceID : D:
DriveType : 5
ProviderName :
FreeSpace :
Size :
VolumeName :
DeviceID : X:
DriveType : 4
ProviderName : \\server01\public
FreeSpace : 36340559872
Size : 36413280256
VolumeName : D_Drive

C:\PS> get-wmiobject win32_networkconnection
LocalName RemoteName
-------------- ------------
x: \\server01\public

# Description
-----------
This example compares the types of file system drives that are displayed by Get-PSDrive to those displayed by using other methods. This example demonstrates different ways to display drives in Windows PowerShell, and it shows that the drives created by using New-PSDrive are accessible only in Windows PowerShell.

The first command uses Get-PSDrive to get all of the file system drives in the Windows PowerShell console. This includes the fixed drives (C: and D:), the mapped network drive (X:), and two Windows PowerShell drives (Y: and Z:) that were created by using New-PsDrive.

A "net use" command, which displays Windows mapped network drives, displays only the X drive. It does not display drives that are created by New-PSDrive. It shows that the X: drive is also mapped to \\Server01\Public.

The third command uses the GetDrives method of the Microsoft .NET Framework System.IO.DriveInfo class. This command gets the Windows file system drives, including drive X:, but it does not get the drives created by New-PSDrive.

The fourth command uses the Get-WmiObject cmdlet to display the instances of the Win32_LogicalDisk class. It returns the C:, D:, and X: drives, but not the drives created by New-PSDrive.

The last command uses the Get-WmiObject cmdlet to display the instances of the Win32_NetworkConnection class. Like "net use", it returns only the X: drive.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=113327
about_Providers
New-PSDrive
Remove-PSDrive
Get-Help
Get-Command
Get-Member

C:\Windows>powershell get-help Get-Item -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole





... Home  
... Impressum
... ColorConsole

... CMD
... Netsh-XP
... Netsh-7
... Netsh-Vista
... Powershell










Download the Windows 10 Starter, Home (Basic Premium), Professional und Ultimate!

... facebook.de
HTTP: ... PS_Windows/en/Get-PSDrive.htm
0.156

Was ist ein Mausrad?

 /

Zum Programmstart einstellen, dass die PCs zu einem bestimmten Zeitpunkt heruntergefahren werden!

 /

Windows 7 Testversion Einschränkung?

 /

Vollständigen Pfad in der Titelleiste anzeigen im Windows 8.1 Explorer!

 /