0% found this document useful (0 votes)
16 views8 pages

PowerShell Command Guide

The document is a comprehensive PowerShell command guide covering various system management tasks, including system information retrieval, scheduled shutdowns, file management, process management, network tasks, system cleanup, user management, and system monitoring. Each section provides specific commands, descriptions, and example outputs to assist users in executing these tasks efficiently. It serves as a practical reference for users looking to utilize PowerShell for system administration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views8 pages

PowerShell Command Guide

The document is a comprehensive PowerShell command guide covering various system management tasks, including system information retrieval, scheduled shutdowns, file management, process management, network tasks, system cleanup, user management, and system monitoring. Each section provides specific commands, descriptions, and example outputs to assist users in executing these tasks efficiently. It serves as a practical reference for users looking to utilize PowerShell for system administration.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

PowerShell Command Guide:

1. System Information Commands


1.1 Check System Information

Command:

Get-ComputerInfo

Description: Provides detailed system information, including OS version, processor details, and
memory.

Example Output:

WindowsVersion : 10.0.19044
CsName : YourComputerName
OsArchitecture : 64-bit
TotalPhysicalMemory : 17034256384

1.2 Check System Uptime

Command:

Get-CimInstance Win32_OperatingSystem | Select-Object LastBootUpTime

Description: Retrieves the last time the system was booted.

Example Output:

2024-12-26T10:34:24.123456-07:00

1.3 List Installed Software

Command:

Get-WmiObject -Class Win32_Product | Select-Object Name, Version


Description: Lists all installed applications and their versions.

Example Output:

Name Version
---- -------
Microsoft Office 365 16.0.15128.20248
Google Chrome 118.0.5993.89

2. Schedule Shutdown

2.1 Shutdown After a Specific Time


Command
shutdown /s /t 3600

2.2 Schedule Restart Instead of Shutdown


Command
shutdown /r /t 1800

2.3 Cancel Scheduled Shutdown


Command
shutdown /a

2.4 Scheduled a Shutdown at specific time


Command
schtasks /create /tn "ShutdownAt10PM" /tr "shutdown /s /f" /sc once /st 22:00

2.4 Shutdown with a Custom Message


Command
shutdown /s /t 300 /c "System will shut down in 5 minutes for maintenance."

3. File and Folder Management


2.1 List Files in a Directory
Command:

Get-ChildItem -Path "C:\YourFolder" -Recurse

Description: Lists all files and subdirectories in the specified folder.

Example Output:

Mode LastWriteTime Length Name


---- ------------- ------ ----
-a--- 12/20/2024 2:00 PM 1024 file1.txt
-a--- 12/22/2024 4:30 PM 5120 file2.docx

2.2 Search for Files by Name

Command:

Get-ChildItem -Path "O:\Python scripts" -Filter *.txt -Recurse

Description: Finds all .txt files within the specified path and its subdirectories. Example
Output:

C:\Documents\notes.txt
C:\Projects\readme.txt

2.3 Copy Multiple Files

Command:

Copy-Item -Path "C:\Source\*" -Destination "D:\Target" -Recurse

Description: Copies all files and folders from the source directory to the target directory.
Example Output:

Copied: C:\Source\file1.txt --> D:\Target\file1.txt


3. Process and Service Management
3.1 List Running Processes

Command:

Get-Process

Description: Displays all currently running processes on the system. Example Output:

Handles NPM(K) PM(K) WS(K) CPU(s) Id ProcessName


------- ------ ----- ----- ------ -- -----------
220 15 12848 35520 0.04 1234 notepad
320 20 32000 80000 1.32 5678 chrome

3.2 Kill a Process by Name

Command:

Stop-Process -Name notepad

Description: Terminates a process by its name. Example:


Stops the notepad process.

3.3 List Running Services

Command:

Get-Service

Description: Shows all Windows services and their current states. Example Output:

Status Name DisplayName


------ ---- -----------
Running Spooler Print Spooler
Stopped WSearch Windows Search
3.4 Start or Stop a Service

Command:

Start-Service -Name "Spooler" # Starts the service


Stop-Service -Name "Spooler" # Stops the service

Description: Manages Windows services.

4. Network Tasks
4.1 Check Active Network Connections

Command:

Get-NetTCPConnection

Description: Lists all active TCP connections. Example Output:

LocalAddress LocalPort RemoteAddress RemotePort State


------------ --------- ------------- ---------- -----
192.168.1.2 50400 142.250.190.78 443 Established

4.2 Find Your IP Address

Command:

Get-NetIPAddress

Description: Displays the IP addresses configured on your system. Example Output:

IPAddress InterfaceAlias AddressFamily


--------- -------------- -------------
192.168.1.100 Ethernet IPv4

4.3 Ping a Website


Command:

Test-Connection google.com

Description: Tests network connectivity to a website. Example Output:

Source Destination Replies


------ ----------- -------
YourPC google.com {64ms, 65ms, 63ms, 62ms}

5. Quick System Cleanup


5.1 Delete Temporary Files

Command:

Remove-Item -Path $env:TEMP\* -Recurse

Description: Deletes all files and folders in the temporary directory. Example Output:

Deleting: C:\Users\YourUser\AppData\Local\Temp\file.tmp

5.2 Empty Recycle Bin

Command:

Clear-RecycleBin

Description: Empties all items in the Recycle Bin. Example Output:

Confirm: Do you want to clear the Recycle Bin? [Y] Yes [N] No [S] Suspend

6. User Management
6.1 List All User Accounts
Command:

Get-LocalUser

Description: Lists all local user accounts. Example Output:

Name Enabled Description


---- ------- -----------
Administrator False Built-in account for administering the computer
YourUser True Your personal account

6.2 Enable or Disable a User Account

Command:

Disable-LocalUser -Name "username" # Disables the account


Enable-LocalUser -Name "username" # Enables the account

Description: Toggles the status of a user account.

7. System Monitoring
7.1 Check Disk Space

Command:

Get-PSDrive -PSProvider FileSystem

Description: Displays disk space usage for each drive. Example Output:

Name Used (GB) Free (GB) Provider


---- --------- --------- --------
C 120 80 FileSystem
D 200 100 FileSystem

7.2 Monitor System Performance


Command:

Get-Counter "\Processor(_Total)\% Processor Time"

Description: Checks CPU usage. Example Output:

Path Instance Name Cooked Value


---- ------------ ------------
\Processor(_Total)\% Processor Time 14.52

7.3 Export Running Processes to a File

Command:

Get-Process | Export-Csv -Path "C:\Processes.csv"

Description: Saves all process details to a CSV file for easy reference. Example Output:

Process data exported to C:\Processes.csv

You might also like