powershell
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| powershell [2022/10/02 09:57] – [Ping with Timestamps] baumi | powershell [2022/11/20 10:19] (current) – [Convert to PCAP] baumi | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| <code powershell> | <code powershell> | ||
| Get-EventLog System -Newest 10000 | ` | Get-EventLog System -Newest 10000 | ` | ||
| - | Where EventId -in 41, | + | Where EventId -In 41, |
| - | Format-Table TimeGenerated, | + | Format-Table TimeGenerated, |
| </ | </ | ||
| - | ==== Ping with Timestamps ==== | + | ===== Ping with Timestamps ===== |
| <code powershell> | <code powershell> | ||
| $target = " | $target = " | ||
| ping -t $target | ForEach {"{0} - {1}" -f (Get-Date), | ping -t $target | ForEach {"{0} - {1}" -f (Get-Date), | ||
| </ | </ | ||
| + | |||
| + | ===== Simple TCP Portscan ===== | ||
| + | <code powershell> | ||
| + | $target = " | ||
| + | $firstport = 1 | ||
| + | $lastport = 65535 | ||
| + | for($port=$firstport; | ||
| + | Test-NetConnection -ComputerName $target -Port $port | ||
| + | } | ||
| + | </ | ||
| + | ===== Packet Capture ===== | ||
| + | ==== Capture ==== | ||
| + | <code powershell> | ||
| + | $duration=90 | ||
| + | $env:HostIP = ( | ||
| + | Get-NetIPConfiguration | | ||
| + | Where-Object { | ||
| + | $_.IPv4DefaultGateway -ne $null -and | ||
| + | $_.NetAdapter.Status -ne " | ||
| + | } | ||
| + | ).IPv4Address.IPAddress | ||
| + | |||
| + | netsh trace start capture=yes IPv4.Address=$env: | ||
| + | Start-Sleep $duration | ||
| + | netsh trace stop | ||
| + | </ | ||
| + | ==== Convert to PCAP ==== | ||
| + | https:// | ||
| + | <code powershell> | ||
| + | Invoke-Webrequest -O etl2pcapng.exe https:// | ||
| + | ./ | ||
| + | </ | ||
| + | ===== Useful Commandlets ===== | ||
| + | <code powershell> | ||
| + | Format-Hex $filename | ||
| + | </ | ||
| + | |||
| + | ===== ActiveDirectory Commandlets/ | ||
| + | |||
| + | ==== Groups / GroupMembers ==== | ||
| + | |||
| + | <code powershell> | ||
| + | $file=" | ||
| + | Get-ADGroup -Filter * -Properties Member ` | ||
| + | | Select-Object Name, | ||
| + | | Export-Csv -Path $file -Delimiter ' | ||
| + | </ | ||
| + | |||
| + | |||
| + | |||
| {{tag>kb windows powershell}} | {{tag>kb windows powershell}} | ||
powershell.1664697446.txt.gz · Last modified: by baumi
