PowerShell Commands
PowerShell Command Reference
This cheat sheet provides a quick reference for essential PowerShell commands, covering various aspects of system administration and scripting. PowerShell is a powerful task automation and configuration management framework from Microsoft, consisting of a command-line shell and associated scripting language built on the .NET framework.
File Management Commands
Efficiently manage files and directories using these PowerShell cmdlets.
| Command | Description |
|---|---|
Get-ChildItem |
List files and directories in a specified location. |
Get-Content <file> |
Retrieve and display the content of a text file. |
Set-Content <file> <content> |
Write or replace the content of a file. |
New-Item <file> |
Create a new file. |
New-Item <directory> -ItemType Directory |
Create a new directory. |
Remove-Item <file> |
Delete a file. |
Remove-Item <directory> -Recurse |
Delete a directory and its contents recursively. |
Rename-Item <file> <new_file> |
Rename a file or directory. |
Copy-Item SOURCE DEST |
Copy a file from a source to a destination. |
Copy-Item SOURCE DEST -Recurse |
Copy a directory and its contents recursively. |
Move-Item SOURCE DEST |
Move a file or directory from one location to another. |
Process Management Commands
Monitor and control running processes on your system.
| Command | Description |
|---|---|
Get-Process |
List all currently running processes. |
Stop-Process -Name <process> |
Terminate a specific process by its name. |
Start-Process <process> |
Launch a new process or application. |
Wait-Process -Name <process> |
Pause script execution until a specified process has finished. |
Service Management Commands
Manage Windows services, including starting, stopping, and configuring them.
| Command | Description |
|---|---|
Get-Service |
List all installed Windows services. |
Start-Service <service> |
Start a stopped service. |
Stop-Service <service> |
Stop a running service. |
Restart-Service <service> |
Stop and then start a service. |
Set-Service <service> -StartupType Automatic |
Configure a service to start automatically when the system boots. |
Set-Service <service> -StartupType Manual |
Configure a service to start only when manually initiated. |
Set-Service <service> -StartupType Disabled |
Prevent a service from starting. |
User Management Commands
Administer local user accounts and group memberships.
| Command | Description |
|---|---|
Get-LocalUser |
List all local user accounts on the machine. |
New-LocalUser <user> |
Create a new local user account. |
Remove-LocalUser <user> |
Delete an existing local user account. |
Set-LocalUser <user> -Password <password> |
Set or change the password for a local user. |
Add-LocalGroupMember -Group Administrators -Member <user> |
Add a specified user to the local Administrators group. |
Remove-LocalGroupMember -Group Administrators -Member <user> |
Remove a specified user from the local Administrators group. |
Network Management Commands
Retrieve network configuration details.
| Command | Description |
|---|---|
Get-NetIPAddress |
Display IP address configuration for network interfaces. |
Get-NetAdapter |
List all network adapters on the system. |
Windows Updates Management
Install and manage Windows updates using PowerShell.
| Command | Description |
|---|---|
Install-Module -Name PSWindowsUpdate |
Install the PSWindowsUpdate module for managing Windows Updates. |
Get-Command -Module PSWindowsUpdate |
List all available commands within the PSWindowsUpdate module. |
Get-WUInstall |
Download and install available Windows updates. |
Windows Features Management
Install or uninstall Windows features and roles.
| Command | Description |
|---|---|
Get-WindowsFeature |
List all available Windows features and their installation status. |
Install-WindowsFeature <feature> |
Install a specified Windows feature. |
Uninstall-WindowsFeature <feature> |
Uninstall a specified Windows feature. |
Remote Computer Management
Connect to and execute commands on remote machines.
| Command | Description |
|---|---|
Enter-PSSession -ComputerName <name> -Credential <user> |
Establish an interactive PowerShell remoting session to a remote computer. |
Exit-PSSession |
Close the current PowerShell remoting session. |
Invoke-Command -ComputerName <name> -ScriptBlock { <command> } |
Execute a specified command or script block on one or more remote computers. |
Invoke-Command -ComputerName <name> -FilePath <script> |
Execute a script file located on the local machine against a remote computer. |
For more in-depth information on PowerShell, refer to the official Microsoft PowerShell documentation.