Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Use Get-PSDrive in Windows PowerShell

Get-PSDrive is a cmdlet in Windows PowerShell that provides information about the drives available in the current session. This includes both physical drives (like C: or D:) and logical drives created by PowerShell providers (such as the registry, certificate store, and environment variables). Understanding how to use Get-PSDrive is crucial for system administrators and engineers who need to manage and troubleshoot storage and other resources on a Windows system.


Examples:
1. Listing All Drives:
To list all the drives available in your PowerShell session, simply run:


   Get-PSDrive

This command will display a table with columns for the drive name, provider, root, current location, and used/available space.


2. Filtering Drives by Provider:
If you want to see only the file system drives, you can filter by the provider:


   Get-PSDrive -PSProvider FileSystem

This will display only the drives that are part of the file system, excluding other types like registry or environment variables.


3. Getting Specific Drive Information:
To get detailed information about a specific drive, such as the C: drive, use:


   Get-PSDrive -Name C

This command will provide detailed information about the C: drive, including its used and free space.


4. Creating a New PSDrive:
You can also create a new drive using the New-PSDrive cmdlet. For example, to map a network share to a drive letter:


   New-PSDrive -Name X -PSProvider FileSystem -Root \\Server\Share -Persist

This will create a new drive X: that maps to the network share \Server\Share and makes it persistent across sessions.


5. Removing a PSDrive:
To remove a previously created PSDrive, use the Remove-PSDrive cmdlet:


   Remove-PSDrive -Name X

This will remove the drive X: from your session.


To share Download PDF