Skip to content

Instantly share code, notes, and snippets.

@ImaginaryStargazer
Created August 17, 2022 17:28
Show Gist options
  • Save ImaginaryStargazer/454fd00476546273293b5c84413e99a1 to your computer and use it in GitHub Desktop.
Save ImaginaryStargazer/454fd00476546273293b5c84413e99a1 to your computer and use it in GitHub Desktop.

Open a 1x1 pixel powershell window to draw as little attention as possible :

powershell -noexit -command "[console]::WindowWidth=1; [console]::WindowHeight=1; [console]::BufferWidth=[console]::WindowWidth"

powershell.exe -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "name_of_script.ps1"

Often you might need to execute an unsigned script that doesn't comply with the current execution policy. An easy way to do this is by bypassing the execution policy for that single process. Example:

powershell.exe -ExecutionPolicy Bypass -File C:\MyUnsignedScript.ps1

Or you can use the shorthand:

powershell -ep Bypass C:\MyUnsignedScript.ps1

start: Win+R

then:

powershell -windowstyle hidden -command get-process | out-file "$ENV:UserProfile\Desktop\loggg.txt"

then: Enter


Get full Wi-Fi connection description of a target network ("NetworkName") in PowerShell, split by pattern and result only the password:

((netsh wlan show profile NetworkName key=clear | Select-String -Pattern "Key Content") -Split ":")[1]

Using findstr instead of Select-String:

((netsh wlan show profile edimax key=clear | findstr "Content") -Split ":")[1].Trim()

This command does everything above, but also trims the output:

(((netsh wlan show profile NetworkName key=clear | Select-String -Pattern "Key Content") -Split ":")[1]).Trim()

Also it's possible to write: netsh wlan show profile name=NetworkName key=clear

Get a trimmed list of all remembered Wi-Fi networks and connections (not including passwords):

ForEach ($i in (netsh wlan show profiles)) { $j = ($i -Split ":")[1]; if ($j) { $j.Trim() } }

Get-Pass function implementation (for code below):

Function Get-Pass { param ($name) $j = (netsh wlan show profile $name key=clear | findstr "Content") -Split ':'; if ($j) { Write-Output $j[1].Trim() } else { Write-Output "<no password>" }}

Get a trimmed list of all remembered Wi-Fi networks and connections (including passwords aka Check all passwords for Wi-Fi networks):

ForEach ($i in (netsh wlan show profiles)) { $j = ($i -Split ":")[1]; if ($j) { $j.Trim() + " : " + (Get-Pass $j.Trim()) }}

Write to a file: Out-File -FilePath . Read a file: Get-Content -Path . Get processes list: Get-Process

Wrap ForEach cmd in $() and add a pipe, like this: $(ForEach ... ) | Out-File "$ENV:UserProfile\Desktop\wifipasswords.txt"


powershell PS power shell windows cmd (not unix, bash, *nix)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment