SlideShare a Scribd company logo
2
Most read
3
Most read
4
Most read
Windows PowerShell Basics – Get PSDrive Info
i | P a g e
Table of Contents
Overview.......................................................................................................................................................1
Applies To..................................................................................................................................................1
Pre-Requisites ...........................................................................................................................................1
PowerShell Script – PSDrive Info...................................................................................................................1
Code Snippet – PSDrive.............................................................................................................................2
PowerShell Output – PSDrive................................................................................................................3
Windows PowerShell Basics – Get PSDrive Info
1 | P a g e
Overview
A Windows PowerShell Drive (PSDrive) is a data store location that you can access like a file system drive
in Windows PowerShell.
The Windows PowerShell providers create some drives for you, such as;
 File System Drives (including C: and D:),
 The Registry Drives (HKCU: and HKLM:),
 The Certificate Drive (Cert:)
You can create your own Windows PowerShell drives as well. These drives are very useful, though they
are available only within Windows PowerShell.
You cannot access them by using other Windows tools, such as File Explorer or Cmd.exe.
Applies To
Tested on Windows 10, Windows 2008 R2 and Windows 2012.
Pre-Requisites
Launch PowerShell Command Console or PowerShell ISE.
To run this script, Execution Policy should be set to either of these “AllSigned” or “RemoteSigned” or
“Unrestricted”, you can get current execution policy by running the command; “Get-ExecutionPolicy”.
Each Policy type and its purpose is shown in the below table.
Policy Type Purpose
Restricted No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned Only scripts signed by a trusted publisher can be run.
RemoteSigned Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted No restrictions; all Windows PowerShell scripts can be run.
PowerShell Script – PSDrive Info
This PowerShell script demonstrates retrieving PowerShell Drive (PSDrive) Information in PowerShell
console.
Windows PowerShell uses the noun PSDrive, additional you can retrieve information as below;
Windows PowerShell Basics – Get PSDrive Info
2 | P a g e
Code Snippet – PSDrive
The code snippet is for demonstrating “PSDrive” information listing, Windows PowerShell uses the noun,
PSDrive. This script will retrieve the available PowerShell drives on to a HTML file.
Clear-Host
#
# Set Output Path and File
#
Set-Location -Path $env:USERPROFILE
Push-Location -Path $env:USERPROFILE
$OutputFile="PSDrives_Info.html"
#
# Remove Old File
#
if ($OutputFile) {
Remove-Item $OutputFile
}
#
# Set HTML Header
#
$Header = @"
<style>
TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;}
TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: red;}
TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;}
</style>
"@
Get-PSDrive | ConvertTo-Html -Property Name,Used,Provider,Root,CurrentLocation -Head $Header |
Out-File -FilePath $OutputFile
Invoke-Item $OutputFile
Windows PowerShell Basics – Get PSDrive Info
3 | P a g e
PowerShell Output – PSDrive
When script is executed; below output will be displayed.

More Related Content

PDF
How To Construct IF and Else Conditional Statements
PDF
How To Create Power Shell Function Mandatory Parameter Value
PDF
Windows PowerShell Basics – How To Create powershell for loop
PDF
How To Disable IE Enhanced Security Windows PowerShell
PDF
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
PDF
How To Check IE Enhanced Security Is Enabled Windows PowerShell
PDF
How To Connect to Active Directory User Validation
PDF
How To Check file exists and Delete PowerShell
How To Construct IF and Else Conditional Statements
How To Create Power Shell Function Mandatory Parameter Value
Windows PowerShell Basics – How To Create powershell for loop
How To Disable IE Enhanced Security Windows PowerShell
How To Create PowerShell Function Mandatory Parameter and Optional Parameter
How To Check IE Enhanced Security Is Enabled Windows PowerShell
How To Connect to Active Directory User Validation
How To Check file exists and Delete PowerShell

What's hot (20)

PDF
Install and Configure RSyslog – CentOS 7 / RHEL 7
PDF
How To Connect To Active Directory PowerShell
PDF
How To Create PowerShell Function
PDF
How To Check and Delete a File via PowerShell
PDF
Install Active Directory PowerShell Module on Windows 10
PDF
How To List Nginx Modules Installed / Complied on CentOS 7
PDF
How To Install and Configure Open SSH Server on Ubuntu
PDF
How To List Files and Display In HTML Format
PDF
How To Install and Configure SNMP on RHEL 7 or CentOS 7
PDF
How To View Current Execution Policy PowerShell
PDF
How To Setup SSH Keys on CentOS 7
PDF
How To Connect Amazon AWS EC2 with Key Pair – Linux
PDF
Bash Script - How To Monitor Application Error Logs and Send Notification
PDF
How To List Files on Remote Server - PowerShell
PDF
How To Create EBS Snapshot and Restore EBS Snapshot – Linux Instance
DOCX
How to Configure Amazon AWS EC2 Elastic IP Address
PDF
How To Install and Configure Apache SSL on CentOS 7
PDF
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
PDF
How To Manage Linux User on RHEL 7
PDF
How to Install and Configure Cacti on Linux
Install and Configure RSyslog – CentOS 7 / RHEL 7
How To Connect To Active Directory PowerShell
How To Create PowerShell Function
How To Check and Delete a File via PowerShell
Install Active Directory PowerShell Module on Windows 10
How To List Nginx Modules Installed / Complied on CentOS 7
How To Install and Configure Open SSH Server on Ubuntu
How To List Files and Display In HTML Format
How To Install and Configure SNMP on RHEL 7 or CentOS 7
How To View Current Execution Policy PowerShell
How To Setup SSH Keys on CentOS 7
How To Connect Amazon AWS EC2 with Key Pair – Linux
Bash Script - How To Monitor Application Error Logs and Send Notification
How To List Files on Remote Server - PowerShell
How To Create EBS Snapshot and Restore EBS Snapshot – Linux Instance
How to Configure Amazon AWS EC2 Elastic IP Address
How To Install and Configure Apache SSL on CentOS 7
Zimbra Troubleshooting - Mails not being Delivered or Deferred or Connection ...
How To Manage Linux User on RHEL 7
How to Install and Configure Cacti on Linux
Ad

Similar to Windows PowerShell Basics - How To List PSDrive Info (20)

PDF
Manage your infrastructure with PowerShell
PPTX
Powershell for Log Analysis and Data Crunching
PPT
PowerShell Core Skills (TechMentor Fall 2011)
PPT
No-script PowerShell v2
PPTX
Powering up on PowerShell - BSides Greenville 2019
PPTX
44CON London 2015: NTFS Analysis with PowerForensics
PPTX
CCI2019 - I've got the Power! I've got the Shell!
PPTX
Power forensics
PPTX
PowerShell for Cyber Warriors - Bsides Knoxville 2016
PDF
Reach the next level with PowerShell
PPTX
Powering up on power shell avengercon - 2018
PPTX
Power shell training
PPTX
The Power of PowerShell: Advanced
PDF
BSidesOK_You_CAN_detect_PowerShell_attacks_v1.1
PPTX
Windows power shell basics
PPTX
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
PPTX
Getting Started With PowerShell Scripting
PPTX
Powershell_Basics_Robin
PPSX
Sunil phani's take on windows powershell
PPTX
Basic PowerShell Toolmaking - Spiceworld 2016 session
Manage your infrastructure with PowerShell
Powershell for Log Analysis and Data Crunching
PowerShell Core Skills (TechMentor Fall 2011)
No-script PowerShell v2
Powering up on PowerShell - BSides Greenville 2019
44CON London 2015: NTFS Analysis with PowerForensics
CCI2019 - I've got the Power! I've got the Shell!
Power forensics
PowerShell for Cyber Warriors - Bsides Knoxville 2016
Reach the next level with PowerShell
Powering up on power shell avengercon - 2018
Power shell training
The Power of PowerShell: Advanced
BSidesOK_You_CAN_detect_PowerShell_attacks_v1.1
Windows power shell basics
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
Getting Started With PowerShell Scripting
Powershell_Basics_Robin
Sunil phani's take on windows powershell
Basic PowerShell Toolmaking - Spiceworld 2016 session
Ad

More from VCP Muthukrishna (12)

PDF
How to Fix Duplicate Packages in YUM on CentOS 7
PDF
How To Install and Configure GNome on CentOS 7
PDF
How To Configure Nginx Load Balancer on CentOS 7
PDF
Nginx bind() to 0.0.0.0:9080 failed
PDF
How To Install and Configure Screen on CentOS 7
PDF
How To Install and Configure Salt Master on Ubuntu
PDF
How To Protect SSH Access with Fail2Ban on RHEL 7
PDF
How To Configure SNMP Logging on RHEL 7
PDF
How To Find Package Installation Date on RHEL 7
PDF
How to Upgrade Openfire on CentOS 7
PDF
How To Reset root Password on CentOS 7
PDF
How To Install and Use ABRT CLI on RHEL 7
How to Fix Duplicate Packages in YUM on CentOS 7
How To Install and Configure GNome on CentOS 7
How To Configure Nginx Load Balancer on CentOS 7
Nginx bind() to 0.0.0.0:9080 failed
How To Install and Configure Screen on CentOS 7
How To Install and Configure Salt Master on Ubuntu
How To Protect SSH Access with Fail2Ban on RHEL 7
How To Configure SNMP Logging on RHEL 7
How To Find Package Installation Date on RHEL 7
How to Upgrade Openfire on CentOS 7
How To Reset root Password on CentOS 7
How To Install and Use ABRT CLI on RHEL 7

Recently uploaded (20)

PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Machine learning based COVID-19 study performance prediction
PDF
Electronic commerce courselecture one. Pdf
PPTX
Spectroscopy.pptx food analysis technology
PPTX
Cloud computing and distributed systems.
PDF
cuic standard and advanced reporting.pdf
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PPT
Teaching material agriculture food technology
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Encapsulation theory and applications.pdf
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
Big Data Technologies - Introduction.pptx
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
KodekX | Application Modernization Development
PPTX
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Machine learning based COVID-19 study performance prediction
Electronic commerce courselecture one. Pdf
Spectroscopy.pptx food analysis technology
Cloud computing and distributed systems.
cuic standard and advanced reporting.pdf
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Teaching material agriculture food technology
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Unlocking AI with Model Context Protocol (MCP)
Diabetes mellitus diagnosis method based random forest with bat algorithm
Big Data Technologies - Introduction.pptx
Reach Out and Touch Someone: Haptics and Empathic Computing
Spectral efficient network and resource selection model in 5G networks
KodekX | Application Modernization Development
Understanding_Digital_Forensics_Presentation.pptx

Windows PowerShell Basics - How To List PSDrive Info

  • 1. Windows PowerShell Basics – Get PSDrive Info i | P a g e Table of Contents Overview.......................................................................................................................................................1 Applies To..................................................................................................................................................1 Pre-Requisites ...........................................................................................................................................1 PowerShell Script – PSDrive Info...................................................................................................................1 Code Snippet – PSDrive.............................................................................................................................2 PowerShell Output – PSDrive................................................................................................................3
  • 2. Windows PowerShell Basics – Get PSDrive Info 1 | P a g e Overview A Windows PowerShell Drive (PSDrive) is a data store location that you can access like a file system drive in Windows PowerShell. The Windows PowerShell providers create some drives for you, such as;  File System Drives (including C: and D:),  The Registry Drives (HKCU: and HKLM:),  The Certificate Drive (Cert:) You can create your own Windows PowerShell drives as well. These drives are very useful, though they are available only within Windows PowerShell. You cannot access them by using other Windows tools, such as File Explorer or Cmd.exe. Applies To Tested on Windows 10, Windows 2008 R2 and Windows 2012. Pre-Requisites Launch PowerShell Command Console or PowerShell ISE. To run this script, Execution Policy should be set to either of these “AllSigned” or “RemoteSigned” or “Unrestricted”, you can get current execution policy by running the command; “Get-ExecutionPolicy”. Each Policy type and its purpose is shown in the below table. Policy Type Purpose Restricted No scripts can be run. Windows PowerShell can be used only in interactive mode. AllSigned Only scripts signed by a trusted publisher can be run. RemoteSigned Downloaded scripts must be signed by a trusted publisher before they can be run. Unrestricted No restrictions; all Windows PowerShell scripts can be run. PowerShell Script – PSDrive Info This PowerShell script demonstrates retrieving PowerShell Drive (PSDrive) Information in PowerShell console. Windows PowerShell uses the noun PSDrive, additional you can retrieve information as below;
  • 3. Windows PowerShell Basics – Get PSDrive Info 2 | P a g e Code Snippet – PSDrive The code snippet is for demonstrating “PSDrive” information listing, Windows PowerShell uses the noun, PSDrive. This script will retrieve the available PowerShell drives on to a HTML file. Clear-Host # # Set Output Path and File # Set-Location -Path $env:USERPROFILE Push-Location -Path $env:USERPROFILE $OutputFile="PSDrives_Info.html" # # Remove Old File # if ($OutputFile) { Remove-Item $OutputFile } # # Set HTML Header # $Header = @" <style> TABLE {border-width: 1px; border-style: solid; border-color: black; border-collapse: collapse;} TH {border-width: 1px; padding: 3px; border-style: solid; border-color: black; background-color: red;} TD {border-width: 1px; padding: 3px; border-style: solid; border-color: black;} </style> "@ Get-PSDrive | ConvertTo-Html -Property Name,Used,Provider,Root,CurrentLocation -Head $Header | Out-File -FilePath $OutputFile Invoke-Item $OutputFile
  • 4. Windows PowerShell Basics – Get PSDrive Info 3 | P a g e PowerShell Output – PSDrive When script is executed; below output will be displayed.