Last active
April 20, 2024 01:25
-
-
Save feliperomero3/7c468fcee059ee11584d63f5332b770e to your computer and use it in GitHub Desktop.
PowerShell Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
choco install tcping | |
choco install git.install | |
choco install gh | |
choco install jq | |
choco install less | |
choco install tree | |
choco install postman | |
choco install speedtest | |
choco install openssl | |
choco install openssl.light | |
choco install linkshellextension | |
choco install python3 | |
choco install python2 | |
choco install tcpview | |
choco install procmon | |
choco install procexp | |
choco install rdcman | |
choco install zoomit | |
choco install sysinternals | |
choco install azure-cosmosdb-emulator | |
choco install powertoys | |
choco install smtp4dev | |
choco install paint.net | |
choco install beyondcompare | |
choco install sql-server-management-studio | |
choco install sql-server-2019 | |
choco install fastcopy.install | |
choco install notepad2 | |
choco install notepad3 | |
choco install putty.install | |
choco install 7zip.install | |
choco install autohotkey.install | |
choco install mediainfo | |
choco install sqlitebrowser.install | |
choco install crystaldiskinfo.install | |
choco install wireshark | |
choco install nodejs.install | |
choco install nodejs-lts | |
choco install screenpresso | |
choco install filezilla | |
choco install gnupg | |
choco install itunes | |
choco install nmap | |
choco install nuget.commandline | |
choco install optipng | |
choco install peazip.install | |
choco install vlc.install | |
choco install pwsh | |
choco install fiddler | |
choco install sliksvn | |
choco install vscode.install | |
choco install reflect-free | |
choco install authy-desktop | |
choco install alldup | |
choco install nvm.install | |
choco install bitvise-ssh-client | |
choco install dotpeek | |
choco install internet-download-manager | |
choco install rufus.install | |
choco install pwgen.install --version 2.9.0 | |
choco install hashcheck | |
choco install sdelete | |
choco install eraser | |
choco install psping | |
choco install pngoptimizer | |
choco install jekyll | |
choco install hugo-extended | |
choco install azurestorageemulator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
REM Grep command equivalent in Windows CMD | |
netstat -na | findstr "127.0.0.1" | |
REM Grep a file for a pattern that matches a regular expression in Windows CMD | |
findstr /i "diff" .\.gitconfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PSGallery Utility modules | |
Install-Module -Name posh-git -Scope CurrentUser | |
Install-Module -Name Indented.Net.IP -Scope CurrentUser | |
Install-Module -Name DockerCompletion -Scope CurrentUser | |
Install-Module -Name Logging -Scope CurrentUser | |
Install-Module -Name PSReadLine -AllowPrerelease | |
Install-Module -Name Microsoft.PowerShell.SecretManagement | |
Install-Module -Name Microsoft.PowerShell.SecretStore | |
Install-Module -Name PSJsonWebToken -Repository PSGallery -Scope CurrentUser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert plain text (string) to type SecureString | |
$SqlAdministratorLoginPassword = ConvertTo-SecureString "Secret12345!" -AsPlainText -Force | |
# "Grep" command equivalent in Windows PowerShell | |
netstat -na | Select-String "127.0.0.1" | |
# If a command in PowerShell returns objects, before parsing, | |
# they should be converted to strings using the Out-String -Stream command | |
Get-Alias | Out-String -Stream | Select-String "iwr" | |
# Grep a file for a pattern that matches a regular expression | |
Select-String "diff" .\.gitconfig | |
# 'where java.exe' equivalent for powershell in Windows CMD | |
❯ (Get-Command java | Select-Object -Property Source).Source | |
C:\Program Files (x86)\Common Files\Oracle\Java\javapath\java.exe | |
# Get Enum values | |
❯ [System.Enum]::GetNames('System.ConsoleColor') | |
Black | |
DarkBlue | |
DarkGreen | |
... | |
# It also works for user created Enums | |
❯ [Flags()] enum FileAttributes { | |
Archive = 1 | |
Compressed = 2 | |
Device = 4 | |
Directory = 8 | |
Encrypted = 16 | |
Hidden = 32 | |
} | |
❯ [System.Enum]::GetNames('FileAttributes') | |
Archive | |
Compressed | |
Device | |
Directory | |
Encrypted | |
Hidden | |
❯ [System.Enum]::GetValues('FileAttributes') | |
Archive | |
Compressed | |
Device | |
Directory | |
Encrypted | |
Hidden | |
# Convert a Unix timestamp to a date (NOTE: This parameter was introduced in PowerShell 7.1) | |
❯ Get-Date -UnixTimeSeconds 1577836800 | |
Wednesday, January 01, 2020 12:00:00 AM | |
# Convert date to Unix timestamp | |
❯ Get-Date -Date 'Wednesday, January 01, 2020 12:00:00 AM' -UFormat "%s" | |
1577836800 | |
# Get an ISO-8601 formatted date (as text) | |
❯ Get-Date -Format o | |
2021-10-08T23:25:20.1420339-05:00 | |
# Get an ISO-8601 UTC formatted date (as text) | |
❯ Get-Date ([datetime]::UtcNow) -Format o | |
2022-05-17T20:53:57.2107547Z | |
# You can also pipe it | |
❯ [datetime]::UtcNow | Get-Date -Format o | |
2022-05-17T20:53:57.2107547Z | |
# Generate a password (all lowercase) | |
# You must have both WSL and the utility pwgen installed | |
❯ wsl -e pwgen -A 12 1 | |
# Generate a password (mixed case) | |
# You must have both WSL and the utility pwgen installed | |
❯ wsl -e pwgen 12 4 | |
# Get current directory size (summary) | |
❯ wsl -- du -hs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment