CMD:

# Show current directory
cd
 
# Change directory
cd <path>
 
# List files and directories
 dir

PowerShell:

# Show current directory
Get-Location
 
# Change directory
Set-Location <path>
 
# List files and directories
Get-ChildItem

File Manipulation

CMD:

# Create a new file
type nul > filename.txt
 
# Copy a file
copy <source> <destination>
 
# Move a file
move <source> <destination>
 
# Delete a file
del <filename>
 
# Delete a directory (and contents)
rmdir /s /q <foldername>

PowerShell:

# Create a new file
New-Item filename.txt -ItemType File
 
# Copy a file
Copy-Item <source> -Destination <destination>
 
# Move a file
Move-Item <source> -Destination <destination>
 
# Delete a file
Remove-Item <filename>
 
# Delete a directory (and contents)
Remove-Item -Recurse -Force <foldername>
 
# Count lines in a file
(Get-Content file.txt).Count
 
# Sort file contents
Get-Content file.txt | Sort-Object | Get-Unique
 
# Find text in a file
Select-String -Path file.txt -Pattern 'string'

Enumeration

cmd

net user





PowerShell

Get-ADUser -Identity "username" -Properties MemberOf | Select-Object -ExpandProperty MemberOf
---
#### Mount Network Shares

**CMD:**
```powershell
# Map network drive
net use Z: \\192.168.1.1\sharename /persistent:yes

# Disconnect network drive
net use Z: /delete

PowerShell:

# Mount a network share
New-PSDrive -Name Z -PSProvider FileSystem -Root "\\192.168.1.1\sharename" -Persist
 
# Unmount a network share
Remove-PSDrive -Name Z

Tools & Package Management

CMD:

# Install Chocolatey (Windows package manager)
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))" && SET "PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin"
 
# Install a package with Chocolatey
choco install <package-name>

PowerShell:

# Install Winget (Windows package manager)
winget install <package-name>
 
# Install a package with Scoop
scoop install <package-name>
 
# Install a module
Install-Module -Name <module-name>
 
# Update all packages
winget upgrade --all

Environment Variables

CMD:

# Show all environment variables
set
 
# Show a specific environment variable
echo %VARIABLENAME%
 
# Set an environment variable
set VARIABLENAME=value
 
# Remove an environment variable
set VARIABLENAME=

PowerShell:

# Show all environment variables
Get-ChildItem Env:
 
# Show a specific environment variable
$env:VARIABLENAME
 
# Set an environment variable
$env:VARIABLENAME = "value1,value2"
 
# Remove an environment variable
Remove-Item Env:\VARIABLENAME

Miscellaneous

CMD:

# Clear the console screen
cls
 
# Shut down the computer
shutdown /s /t 0
 
# Restart the computer
shutdown /r /t 0

PowerShell:

# Clear the console screen
Clear-Host
 
# Shut down the computer
Stop-Computer -Force
 
# Restart the computer
Restart-Computer -Force

History & Cleanup

Windows CMD

# CMD does not persist history by default like bash. Closing the session clears it.
# No built-in persistent history file in standard CMD sessions.

PowerShell

# Clear history in session
Clear-History

# Remove history file (PowerShell 5+)
Remove-Item (Get-PSReadlineOption).HistorySavePath