Powershell commands


Print wifi stored passwords

netsh wlan show profiles

netsh wlan show profile name="MyWiFiNetwork" key=clear

Update all sw packages from cmd

List all

winget upgrade

Upgrade all

winget upgrade --all

Upgrade specific

winget upgrade "[NameTag]"

Wsl (Linux subsystem for windows)

List version

wsl --list --verbose

update

wsl --update

Get battery report

powercfg /batteryreport /output "$env:USERPROFILE\Documents\battery-report.html"

Ver logins

Exitosos

Get-EventLog Security -InstanceId 4624 | Select -Last 4

Fallidos

Get-EventLog Security -InstanceId 4625 | Select -Last 4

Conexiones remotas asociadas a personas filtrando dwm/umfd y system

Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4624} | Where-Object { ($_.Properties[8].Value -in 2,3,10) -and ($_.Properties[5].Value -notmatch 'DWM|UMFD|SYSTEM|LOCAL SERVICE|NETWORK SERVICE|ANONYMOUS LOGON') } | Select-Object TimeCreated, @{Name='User';Expression={$_.Properties[5].Value}}, @{Name='LogonType';Expression={$_.Properties[8].Value}}, @{Name='IP';Expression={$_.Properties[18].Value}} | Sort-Object TimeCreated -Descending | Select-Object -First 20

Listar grupos

whoami /groups

Provide with admin privileges

net localgroup Administrators /add username

Provide with rdp privileges

net localgroup "Remote Desktop Users" /add username

List all local groups with name + description

Get-LocalGroup | Select-Object Name, Description

List all members of each local group

Get-LocalGroup | ForEach-Object { Write-Host "`n==== Group: $($_.Name) ====" -ForegroundColor Cyan Get-LocalGroupMember $_.Name | Format-Table Name, ObjectClass, PrincipalSource -AutoSize }

Kill a process by name

taskkill /im nameofprogram.exe

Add application or bat to Windows Startup (Registry)

Guarantees running from the app directory instead of System32

Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppName" -Value 'cmd.exe /c "cd /d C:\Path\To\AppDirectory && app.exe"'

Remove application from Windows Startup (Registry)

Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Run" -Name "AppName"

List connected devices & Scan network

List devices connected to network interfaces

arp -a

Install Nmap

winget install nmap

Ping scan local subnet (dynamic type interface)

& "C:\Program Files (x86)\Nmap\nmap.exe" -sn -PR 10.198.109.0/24