Netsh: A Complete Guide to Managing Your Windows Networks and Passwords
Learn how to use netsh to view and manage your Windows networks and saved passwords.
I
InSkillCoach
· min
Netsh: A Complete Guide to Managing Your Windows Networks and Passwords
Netsh is a powerful tool for managing network configurations on Windows. This guide shows you how to use it to view and manage your saved networks and passwords.
1. Viewing Networks
Listing Network Interfaces
# Display all network interfaces
netsh interface show interface
# Display the details of a specific interface
netsh interface show interface name="Ethernet"
# Display IP configurations
netsh interface ipv4 show addresses
Adapter Configuration
# Display wireless adapters
netsh wlan show interfaces
# Display available networks
netsh wlan show networks
# Display saved profiles
netsh wlan show profiles
2. Managing Network Passwords
Viewing Saved Passwords
# Display Wi-Fi profiles with passwords
netsh wlan show profiles key=clear
# Display the passwords for a specific profile
netsh wlan show profile name="NomDuProfil" key=clear
# Export Wi-Fi profiles
netsh wlan export profile folder="C:\WiFiProfiles" key=clear
Managing Profiles
# Delete a Wi-Fi profile
netsh wlan delete profile name="NomDuProfil"
# Create a new profile
netsh wlan add profile filename="C:\WiFiProfiles\profil.xml"
# Modify an existing profile
netsh wlan set profileparameter name="NomDuProfil" keyMaterial="NouveauMotDePasse"
3. IP Configuration
Viewing IP Configurations
# Display the IPv4 configuration
netsh interface ipv4 show addresses
# Display the IPv6 configuration
netsh interface ipv6 show addresses
# Display routes
netsh interface ipv4 show routes
Modifying Configurations
# Configure a static IP address
netsh interface ipv4 set address name="Ethernet" static 192.168.1.100 255.255.255.0 192.168.1.1
# Configure DNS
netsh interface ipv4 set dns name="Ethernet" static 8.8.8.8
netsh interface ipv4 add dns name="Ethernet" 8.8.4.4 index=2
4. Useful Scripts
Checking the Network Configuration
# Network verification script
function Test-NetworkConfig {
Write-Host "=== Interfaces Réseau ==="
netsh interface show interface
Write-Host "`n=== Configuration IP ==="
netsh interface ipv4 show addresses
Write-Host "`n=== Routes ==="
netsh interface ipv4 show routes
Write-Host "`n=== Profils WiFi ==="
netsh wlan show profiles
}
Managing Wi-Fi Profiles
# Wi-Fi profile management script
function Manage-WiFiProfiles {
param (
[Parameter(Mandatory=$true)]
[string]$Action,
[string]$ProfileName
)
switch ($Action) {
"list" {
netsh wlan show profiles
}
"show" {
netsh wlan show profile name=$ProfileName key=clear
}
"delete" {
netsh wlan delete profile name=$ProfileName
}
"export" {
netsh wlan export profile name=$ProfileName folder="C:\WiFiProfiles" key=clear
}
}
}
5. Network Security
Firewall Configuration
# Display firewall rules
netsh advfirewall firewall show rule name=all
# Display firewall profiles
netsh advfirewall show allprofiles
# Display security settings
netsh advfirewall show global
Protecting Connections
# Enable the firewall
netsh advfirewall set allprofiles state on
# Configure security rules
netsh advfirewall firewall add rule name="Allow RDP" dir=in action=allow protocol=TCP localport=3389
6. Best Practices
Backing Up Configurations
# Network configuration backup script
function Backup-NetworkConfig {
$backupPath = "C:\NetworkBackup"
if (-not (Test-Path $backupPath)) {
New-Item -ItemType Directory -Path $backupPath
}
# Backup Wi-Fi profiles
netsh wlan export profile folder="$backupPath\WiFi" key=clear
# Backup IP configurations
netsh interface ipv4 show addresses > "$backupPath\ipv4_config.txt"
netsh interface ipv6 show addresses > "$backupPath\ipv6_config.txt"
}
Cleaning Up Configurations
# Configuration cleanup script
function Cleanup-NetworkConfig {
# Remove unused Wi-Fi profiles
$profiles = netsh wlan show profiles | Select-String "All User Profile" | ForEach-Object {$_.Line.Split(":")[1].Trim()}
foreach ($profile in $profiles) {
if (-not (Test-NetConnection -ComputerName $profile -WarningAction SilentlyContinue).PingSucceeded) {
netsh wlan delete profile name=$profile
}
}
}
Conclusion
Managing networks with netsh requires:
- A good understanding of the commands
- Careful attention to security
- Regular backups
- Precise documentation
Key takeaways:
- Check configurations regularly
- Back up important profiles
- Clean up unused configurations
- Keep passwords secure
- Document your changes
About InSkillCoach
Training and technology expert
Coach specializing in advanced technologies and AI, backed by GNeurone Inc.
Certifications:
- AWS Certified Solutions Architect – Professional
- Google Cloud certifications
- Microsoft Certified: DevOps Engineer Expert
- Certified Kubernetes Administrator (CKA)
- CompTIA Security+
1.8k
215
Comments
Comments are powered by GitHub Discussions
Sign in with GitHub to join the discussion