User Tools

Site Tools


windows:windows_cheatsheet

[CHEATSHEET] windows/powershell

OMG! windows cheatsheet!

history

history list

Get-History

execute history command

Invoke-History 1

find

find -type f

Get-ChildItem -Path . -Recurse -Attributes Archive

grep

grep string file

Select-String -pattern "ams-pve-bamboo" file.log

tail

tail -f file

Get-Content filename.log -Wait

curl

Invoke-RestMethod -Uri "http://127.0.0.1:8080/requests/status.xml?command=pl_pause" -Method Get

http basic authentication

$user=""
$pass="thepassword"
$base64Auth=[Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("${user}:${pass}"))
$headers = @{"Authorization" = "Basic $base64Auth"}
$r=Invoke-RestMethod -Uri http://127.0.0.1:8080/?command=pl_pause -Headers $headers -Method Get
$r

dig/nslookup

Resolve-DnsName -Name google.com -Server 127.0.0.1

network config

ifconfig

Get-NetAdapter

and

Get-NetIPInterface

Network Routing

ip route show

route print

Add static routes

New-NetRoute -DestinationPrefix <destination_network> -InterfaceIndex <interface_index> -NextHop <next_hop_ip>

Example:

New-NetRoute -DestinationPrefix 192.168.56.0/24 -InterfaceIndex 6 -NextHop 192.168.3.230

For InterfaceIndex best use Get-NetIPInterface

Other stuff

resolv.conf

Get-DnsClientServerAddress

zero/empty a file

Clear-Content C:\Temp\TestFile.txt
windows/windows_cheatsheet.txt · Last modified: by dodger