PowerShell commands
Cross-platform task automation and configuration management shell
Navigation & File System
Get-LocationPrint the current working directory path
pwdAlias for Get-Location, prints the current directory
Set-Location <path>Change the current working directory
cd <path>Alias for Set-Location, change the current directory
cd ..Move up one level to the parent directory
cd ~Navigate to the current user's home directory
cd -Switch to the previously visited directory
Push-Location <path>Save the current location and change to a new path
Pop-LocationReturn to the directory saved by Push-Location
Get-ChildItemList files and directories in the current location
lsAlias for Get-ChildItem, list directory contents
dirAlias for Get-ChildItem, list directory contents
Get-ChildItem -ForceList all items including hidden files and system files
Get-ChildItem -RecurseList all files and folders recursively
Get-ChildItem -Filter <pattern>List items matching a specific filter pattern
Get-ChildItem -NameList only the names of files and directories
Get-ChildItem -FileList only files, excluding directories
Get-ChildItem -DirectoryList only directories, excluding files
Get-ChildItem | Sort-Object LengthList files sorted by file size
Get-ChildItem | Sort-Object LastWriteTimeList files sorted by last modified time
File & Directory Operations
New-Item <name> -ItemType FileCreate a new empty file
New-Item <name> -ItemType DirectoryCreate a new directory
mkdir <name>Create a new directory (alias/function)
New-Item -Path <path> -ItemType Directory -ForceCreate nested directories, creating parents as needed
Remove-Item <path>Delete a file or empty directory
Remove-Item <path> -RecurseRecursively delete a directory and all its contents
Remove-Item <path> -ForceForcefully delete a file without prompting
Remove-Item <path> -Recurse -ForceForcefully and recursively delete a directory
Remove-Item <path> -ConfirmDelete a file with a confirmation prompt
Copy-Item <source> <destination>Copy a file or directory to a new location
Copy-Item <source> <destination> -RecurseRecursively copy a directory and its contents
Copy-Item <source> <destination> -ForceCopy a file, overwriting the destination if it exists
Copy-Item <source> <destination> -PassThruCopy an item and return the new item object
Move-Item <source> <destination>Move or rename a file or directory
Move-Item <source> <destination> -ForceForcefully move a file, overwriting the destination
Rename-Item <path> <newname>Rename a file or directory
Test-Path <path>Check if a file, directory, or registry key exists
Test-Path <path> -PathType LeafCheck if a path is a file
Test-Path <path> -PathType ContainerCheck if a path is a directory
Join-Path <parent> <child>Combine path components into a single path string
Split-Path <path>Return the parent directory of a path
Split-Path <path> -LeafReturn only the filename from a path
Resolve-Path <path>Resolve a path to its absolute form
New-Item -ItemType SymbolicLink -Path <link> -Target <target>Create a symbolic link pointing to a target
New-Item -ItemType HardLink -Path <link> -Target <target>Create a hard link to a file
Get-Item <path>Get a file or directory object at a specified path
Get-ItemProperty <path>Get the properties of an item at a specified path
File Viewing & Content
Get-Content <file>Read and display the contents of a file
cat <file>Alias for Get-Content, reads a file's contents
Get-Content <file> -TotalCount <n>Read only the first <n> lines of a file
Get-Content <file> -Tail <n>Read only the last <n> lines of a file
Get-Content <file> -WaitFollow a file for new content in real-time
Get-Content <file> -Encoding UTF8Read a file using a specific character encoding
Get-Content <file> -RawRead a file as a single string instead of line by line
Set-Content <file> <value>Write content to a file, replacing existing content
Add-Content <file> <value>Append content to the end of a file
Clear-Content <file>Delete the contents of a file without deleting the file
Out-File <file>Send output to a file (pipeline-friendly Set-Content)
Out-File <file> -AppendAppend pipeline output to a file
"<text>" | Out-File <file>Write a string to a file via the pipeline
More <file>Display file content one page at a time
Invoke-Item <file>Open a file with its default associated application
notepad <file>Open a file in Notepad
code <file>Open a file in Visual Studio Code
Get-Content <file> | Measure-Object -LineCount the number of lines in a file
Get-Content <file> | Measure-Object -WordCount the number of words in a file
Get-Content <file> | Measure-Object -CharacterCount the number of characters in a file
Search & Filter
Get-ChildItem -Recurse -Filter <pattern>Recursively search for files matching a name pattern
Get-ChildItem -Recurse -Include <pattern>Recursively include only files matching a pattern
Get-ChildItem -Recurse -Exclude <pattern>Recursively list items excluding files matching a pattern
Select-String <pattern> <file>Search for a text pattern in a file
Select-String -Pattern <pattern> -Path <file>Search for a regex pattern in a file
Select-String -Pattern <pattern> -Path <path> -RecurseRecursively search for a pattern in all files under a path
Select-String -CaseSensitive <pattern> <file>Search for a pattern with case-sensitive matching
Select-String -NotMatch <pattern> <file>Print lines that do NOT match the pattern
Select-String -List <pattern> <file>Print only the names of files that contain matches
Select-String <pattern> <file> | Select-Object LineNumberDisplay line numbers of matching results
Where-Object { $_ -like '<pattern>' }Filter pipeline objects using a wildcard pattern
Where-Object { $_ -match '<regex>' }Filter pipeline objects using a regular expression
Where-Object { $_ -eq '<value>' }Filter pipeline objects by exact equality
Where-Object { $_ -ne '<value>' }Filter pipeline objects by non-equality
Where-Object { $_ -gt <value> }Filter pipeline objects greater than a value
Where-Object { $_ -lt <value> }Filter pipeline objects less than a value
Where-Object { $_ -contains '<value>' }Filter pipeline objects that contain a specific value
Find-Module <pattern>Search for modules in PowerShell Gallery
Get-Command <pattern>Search for commands matching a name pattern
Get-Command -Verb <verb>Find all commands with a specific verb
Get-Command -Noun <noun>Find all commands with a specific noun
Get-Command -Module <module>List all commands from a specific module
Text Processing & Output Formatting
Write-Output <text>Write text to the standard output stream
Write-Host <text>Write text directly to the console
Write-Host <text> -ForegroundColor <color>Write colored text to the console
Write-Warning <text>Write a warning message to the warning stream
Write-Error <text>Write an error message to the error stream
Write-Verbose <text>Write a verbose message (visible only with -Verbose)
Write-Debug <text>Write a debug message (visible only with -Debug)
Write-Information <text>Write informational output to the information stream
Format-ListDisplay properties as a list, one property per line
Format-TableDisplay output as a formatted table
Format-Table -AutoSizeDisplay a table with auto-adjusted column widths
Format-Table -Property <prop1>,<prop2>Display only specific properties in a table
Format-WideDisplay values in a wide, multi-column layout
Out-GridViewDisplay output in an interactive graphical grid view
Out-GridView -PassThruDisplay a grid view and return selected rows to the pipeline
ConvertTo-JsonConvert an object to a JSON-formatted string
ConvertTo-Json -Depth <n>Convert an object to JSON with a specified nesting depth
ConvertFrom-Json <string>Convert a JSON string into a PowerShell object
ConvertTo-CsvConvert an object to a CSV-formatted string
ConvertFrom-CsvConvert CSV data to PowerShell objects
ConvertTo-HtmlConvert an object to an HTML representation
ConvertTo-XmlConvert an object to an XML representation
Export-Csv <file>Export pipeline objects to a CSV file
Import-Csv <file>Import a CSV file and create objects from its rows
Export-Clixml <file>Export objects to an XML file preserving type information
Import-Clixml <file>Import objects from a Clixml file
Select-Object -Property <props>Select specific properties of objects from the pipeline
Select-Object -First <n>Select only the first <n> objects from the pipeline
Select-Object -Last <n>Select only the last <n> objects from the pipeline
Select-Object -UniqueSelect only unique objects from the pipeline
Select-Object -ExpandProperty <prop>Extract the value of a single property from objects
Sort-ObjectSort objects in the pipeline
Sort-Object -Property <prop>Sort objects by a specific property
Sort-Object -DescendingSort objects in descending order
Sort-Object -UniqueSort objects and remove duplicates
Group-Object -Property <prop>Group objects by the value of a specified property
Measure-ObjectCalculate numeric statistics on pipeline objects
Measure-Object -SumCalculate the sum of a property across pipeline objects
Measure-Object -AverageCalculate the average of a property
Measure-Object -MaximumFind the maximum value of a property
Measure-Object -MinimumFind the minimum value of a property
Tee-Object <file>Send pipeline output to a file and continue the pipeline
Process Management
Get-ProcessList all currently running processes
Get-Process <name>Get information about processes matching a name
Get-Process -Id <pid>Get information about a process by its ID
Get-Process | Sort-Object CPU -DescendingList processes sorted by CPU usage
Get-Process | Sort-Object WorkingSet -DescendingList processes sorted by memory usage
Start-Process <program>Start a new process
Start-Process <program> -ArgumentList <args>Start a process with specific arguments
Start-Process <program> -WaitStart a process and wait for it to finish
Start-Process <program> -Verb RunAsStart a process with elevated administrator privileges
Start-Process <program> -WindowStyle HiddenStart a process without showing a window
Start-Process <program> -RedirectStandardOutput <file>Start a process and redirect its output to a file
Stop-Process <name>Stop all processes with the specified name
Stop-Process -Id <pid>Stop a specific process by its ID
Stop-Process <name> -ForceForcefully terminate a process
Wait-Process <name>Wait for a process to finish before continuing
Wait-Process -Id <pid> -Timeout <seconds>Wait for a process up to a specified timeout
Get-JobGet all background jobs in the current session
Start-Job -ScriptBlock { <commands> }Start a command as a background job
Start-Job -FilePath <script>Run a script file as a background job
Receive-Job <job>Get the output from a background job
Wait-Job <job>Wait for a background job to complete
Stop-Job <job>Stop a background job
Remove-Job <job>Delete a background job and its results
Invoke-Command -ScriptBlock { <commands> }Run commands in a local or remote script block
Invoke-Command -ComputerName <host> -ScriptBlock { <cmds> }Run commands on a remote computer
Start-Sleep <seconds>Pause script execution for a specified number of seconds
Start-Sleep -Milliseconds <ms>Pause script execution for a specified number of milliseconds
System Information
Get-HostGet information about the current PowerShell host
$PSVersionTableDisplay the PowerShell version and related information
Get-ComputerInfoGet comprehensive system and operating system information
Get-ComputerInfo -Property <prop>Get a specific system information property
Get-WmiObject Win32_OperatingSystemGet operating system information via WMI
Get-WmiObject Win32_ComputerSystemGet computer system hardware information via WMI
Get-WmiObject Win32_ProcessorGet CPU information via WMI
Get-WmiObject Win32_PhysicalMemoryGet RAM module information via WMI
Get-WmiObject Win32_DiskDriveGet physical disk drive information via WMI
Get-PSDriveList all PowerShell drives including file system, registry, and more
Get-PSDrive -PSProvider FileSystemList only file system drives
Get-VolumeGet information about disk volumes
Get-DiskGet information about physical disks
Get-PartitionGet information about disk partitions
Get-DateGet the current date and time
Get-Date -Format "yyyy-MM-dd"Get the current date formatted as YYYY-MM-DD
Get-Date -Format "HH:mm:ss"Get the current time formatted as HH:MM:SS
[System.DateTime]::UtcNowGet the current UTC date and time
Get-TimeZoneGet the current system time zone
Get-TimeZone -ListAvailableList all available time zones
Get-UICultureGet the current UI culture setting
Get-CultureGet the current regional and culture settings
$env:COMPUTERNAMEGet the name of the current computer
$env:USERNAMEGet the current logged-in username
$env:USERPROFILEGet the path to the current user's profile directory
$env:TEMPGet the path to the temporary files directory
$env:PATHGet the system PATH environment variable
Get-ChildItem Env:List all environment variables
$env:<variable>Get the value of a specific environment variable
$env:<variable> = <value>Set an environment variable for the current session
[System.Environment]::GetEnvironmentVariable(<name>, <scope>)Get an environment variable from a specific scope
[System.Environment]::SetEnvironmentVariable(<n>, <v>, <scope>)Set an environment variable persistently at a specified scope
Get-HotFixGet a list of installed Windows updates and hotfixes
Get-UptimeGet the system uptime
Network
Test-Connection <host>Send ICMP ping requests to test connectivity to a host
Test-Connection <host> -Count <n>Send exactly <n> ping packets to a host
Test-Connection <host> -QuietPing a host and return only true or false
Test-NetConnection <host>Test a network connection and display diagnostic info
Test-NetConnection <host> -Port <port>Test if a specific TCP port is open on a host
Test-NetConnection <host> -TraceRouteTrace the route to a remote host
Resolve-DnsName <domain>Perform a DNS query for a domain name
Resolve-DnsName <domain> -Type <type>Perform a DNS query for a specific record type
Get-NetAdapterGet all network adapter properties
Get-NetAdapter | Where-Object Status -eq 'Up'List only active network adapters
Get-NetIPAddressGet all IP address configurations
Get-NetIPAddress -AddressFamily IPv4Get all IPv4 address configurations
Get-NetIPConfigurationGet comprehensive IP configuration for all adapters
Get-NetRouteGet all entries in the IP routing table
Get-NetTCPConnectionGet all current TCP connections
Get-NetTCPConnection -State ListenList all listening TCP ports
Get-NetTCPConnection -LocalPort <port>Get TCP connections on a specific local port
Get-NetUDPEndpointGet all current UDP endpoints
Invoke-WebRequest <url>Download content from a URL
Invoke-WebRequest <url> -OutFile <file>Download a URL and save it to a file
Invoke-WebRequest <url> -Method POST -Body <data>Send a POST request with data to a URL
Invoke-WebRequest <url> -Headers @{<key>=<value>}Send a request with custom HTTP headers
Invoke-WebRequest <url> -Credential <cred>Send a request with authentication credentials
Invoke-RestMethod <url>Send an HTTP request to a REST API endpoint
Invoke-RestMethod <url> -Method GETSend a GET request to a REST API
Invoke-RestMethod <url> -Method POST -Body <json> -ContentType 'application/json'Send a JSON POST request to a REST API
Invoke-RestMethod <url> -Headers @{Authorization='Bearer <token>'}Send an authenticated API request with a bearer token
New-NetFirewallRule -DisplayName <name> -Direction Inbound -Port <port> -Protocol TCP -Action AllowCreate a new inbound firewall rule
Get-NetFirewallRuleGet all firewall rules
Enable-NetFirewallRule -DisplayName <name>Enable a firewall rule by display name
Disable-NetFirewallRule -DisplayName <name>Disable a firewall rule
Remove-NetFirewallRule -DisplayName <name>Delete a firewall rule
Registry
Get-Item HKLM:\<path>Get a registry key object
Get-ChildItem HKLM:\<path>List subkeys and values under a registry key
Get-ItemProperty HKLM:\<path>Get the values of a registry key
Get-ItemProperty HKLM:\<path> -Name <valuename>Get a specific registry value
New-Item HKLM:\<path>Create a new registry key
New-ItemProperty HKLM:\<path> -Name <n> -Value <v> -PropertyType <type>Create a new registry value in a key
Set-ItemProperty HKLM:\<path> -Name <n> -Value <v>Set or update a registry value
Remove-Item HKLM:\<path>Delete a registry key
Remove-Item HKLM:\<path> -RecurseDelete a registry key and all its subkeys
Remove-ItemProperty HKLM:\<path> -Name <n>Delete a specific registry value
Test-Path HKLM:\<path>Check if a registry key exists
Copy-Item HKLM:\<source> HKLM:\<dest>Copy a registry key to another location
Module & Package Management
Get-ModuleList all modules imported in the current session
Get-Module -ListAvailableList all modules installed and available to import
Import-Module <module>Import a module into the current session
Import-Module <module> -ForceForcefully reimport a module, refreshing it
Remove-Module <module>Remove an imported module from the current session
Install-Module <module>Download and install a module from PowerShell Gallery
Install-Module <module> -Scope CurrentUserInstall a module for the current user only
Install-Module <module> -ForceForce install a module, reinstalling if already present
Update-Module <module>Update an installed module to its latest version
Update-ModuleUpdate all installed modules to their latest versions
Uninstall-Module <module>Uninstall an installed module
Find-Module <keyword>Search for a module in PowerShell Gallery
Find-Module <keyword> -Repository PSGallerySearch for a module specifically in the PSGallery repository
Get-InstalledModuleList all modules installed from a repository
Register-PSRepositoryRegister a new PowerShell module repository
Get-PSRepositoryList all registered PowerShell repositories
Set-PSRepository -Name PSGallery -InstallationPolicy TrustedMark PSGallery as a trusted installation source
Save-Module <module> -Path <path>Download a module to a folder without installing it
Permissions & Security
Get-Acl <path>Get the access control list (permissions) of a file or directory
Set-Acl <path> -AclObject <acl>Apply an access control list to a file or directory
Get-Acl <path> | Format-ListDisplay detailed ACL information for a path
Get-ExecutionPolicyGet the current PowerShell script execution policy
Get-ExecutionPolicy -ListList execution policies for all scopes
Set-ExecutionPolicy RemoteSignedAllow local scripts and signed remote scripts to run
Set-ExecutionPolicy UnrestrictedAllow all scripts to run without restriction
Set-ExecutionPolicy RestrictedPrevent all scripts from running
Set-ExecutionPolicy -Scope CurrentUser RemoteSignedSet the execution policy for the current user only
Get-LocalUserGet all local user accounts
New-LocalUser -Name <n> -Password <p>Create a new local user account
Remove-LocalUser <name>Delete a local user account
Get-LocalGroupList all local groups
Add-LocalGroupMember -Group <g> -Member <m>Add a user to a local group
Remove-LocalGroupMember -Group <g> -Member <m>Remove a user from a local group
Get-LocalGroupMember -Group <group>List members of a local group
ConvertTo-SecureString <text> -AsPlainText -ForceConvert a plain text string to a SecureString
Get-CredentialPrompt for credentials and return a credential object
Get-AuthenticodeSignature <file>Get the digital signature information of a file
Set-AuthenticodeSignature <file> <cert>Add a digital signature to a script or file
Services & Events
Get-ServiceGet the status of all Windows services
Get-Service <name>Get the status of a specific service
Get-Service | Where-Object Status -eq 'Running'Get only services that are currently running
Start-Service <name>Start a Windows service
Stop-Service <name>Stop a running Windows service
Restart-Service <name>Restart a Windows service
Suspend-Service <name>Pause a running Windows service
Resume-Service <name>Resume a suspended Windows service
Set-Service <name> -StartupType AutomaticConfigure a service to start automatically
Set-Service <name> -StartupType DisabledDisable a service from starting
New-Service -Name <n> -BinaryPathName <path>Create a new Windows service
Remove-Service <name>Delete a Windows service
Get-EventLog -LogName <log>Read entries from a Windows event log
Get-EventLog -LogName System -Newest <n>Get the most recent entries from the System event log
Get-EventLog -LogName Application -EntryType ErrorGet error entries from the Application event log
Get-WinEvent -LogName <log>Get events from a Windows event log (modern approach)
Get-WinEvent -FilterHashtable @{LogName='System';Level=2}Get error-level events from the System log
Clear-EventLog -LogName <log>Clear all entries from an event log
New-EventLog -LogName <n> -Source <s>Create a new event log with a specific source
Write-EventLog -LogName <log> -Source <s> -EventId <id> -Message <msg>Write a custom event to an event log
Scripting & Automation
powershell -File <script>.ps1Execute a PowerShell script file
powershell -Command "<command>"Execute a PowerShell command string directly
& '<script>.ps1'Run a script file using the call operator
. '.\<script>.ps1'Dot-source a script to run it in the current scope
$variable = <value>Assign a value to a variable
[string]$variable = <value>Declare a strongly-typed string variable
[int]$variable = <value>Declare a strongly-typed integer variable
[bool]$variable = $trueDeclare a boolean variable
$array = @(<items>)Create an array
$hash = @{<key>=<value>}Create a hashtable (dictionary)
if (<condition>) { ... } else { ... }If-else conditional block
if (<condition>) { ... } elseif (<cond>) { ... } else { ... }If-elseif-else conditional block
switch (<variable>) { <value> { ... } }Switch statement for matching multiple conditions
foreach ($item in $collection) { ... }Loop through each item in a collection
for ($i=0; $i -lt $n; $i++) { ... }C-style for loop
while (<condition>) { ... }Execute a block while a condition is true
do { ... } while (<condition>)Execute a block at least once, then repeat while condition is true
do { ... } until (<condition>)Execute a block until a condition becomes true
breakExit a loop immediately
continueSkip the current iteration and continue to the next
return <value>Return a value from a function
function <Name> { param(<params>) ... }Define a reusable function with parameters
function <Name> { [CmdletBinding()] param() begin{} process{} end{} }Define an advanced function with pipeline support
try { ... } catch { ... } finally { ... }Structured error handling with try-catch-finally
$ErrorActionPreference = 'Stop'Set errors to terminate as exceptions globally
trap { ... }Define a trap to handle terminating errors
throw <message>Throw a terminating error with a custom message
$Error[0]Access the most recent error that occurred
Invoke-Expression <string>Evaluate and run a string as a PowerShell expression
& { <scriptblock> }Invoke a script block directly
param(<parameter>)Define parameters for a script or function
[Parameter(Mandatory=$true)]Mark a parameter as required
[ValidateSet(<values>)]Restrict a parameter to a set of allowed values
[ValidateRange(<min>, <max>)]Restrict a numeric parameter to a valid range
Measure-Command { <expression> }Measure how long a command or expression takes to run
Register-ScheduledTaskRegister a new scheduled task in Task Scheduler
Get-ScheduledTaskGet all scheduled tasks
Start-ScheduledTask -TaskName <name>Manually run a scheduled task
Unregister-ScheduledTask -TaskName <name>Delete a scheduled task
Help & Discovery
Get-Help <command>Display help documentation for a command
Get-Help <command> -FullDisplay complete help documentation including all parameters
Get-Help <command> -ExamplesDisplay usage examples for a command
Get-Help <command> -OnlineOpen the online documentation for a command in a browser
Get-Help <command> -Parameter <param>Get help for a specific parameter of a command
Update-HelpDownload and update the local help documentation
Get-CommandList all available PowerShell commands
Get-Command *<keyword>*Find commands whose name contains a keyword
Get-AliasList all defined aliases
Get-Alias <alias>Find the command that an alias points to
New-Alias <alias> <command>Create a new alias for a command
Set-Alias <alias> <command>Create or update an alias
Remove-Alias <alias>Remove a defined alias
Get-MemberDisplay the properties and methods of a pipeline object
<object> | Get-MemberExplore what properties and methods an object has
Get-PSDriveList all accessible PowerShell drives
Get-PSProviderList all available PowerShell providers
Show-CommandDisplay a graphical interface to help build a command
Clear-HostClear the PowerShell console screen
clsAlias for Clear-Host, clears the console
ExitExit the current PowerShell session