powershell
This is an old revision of the document!
Table of Contents
Useful Powershell Commands
Get Systemboot/Reboot/Shutdown Events
Get-EventLog System -Newest 10000 | ` Where EventId -In 41,1074,1076,6005,6006,6008,6009,6013 | ` Format-Table TimeGenerated,EventId,UserName,Message -AutoSize -Wrap
Ping with Timestamps
$target = "www.google.com" ping -t $target | ForEach {"{0} - {1}" -f (Get-Date),$_}
Simple TCP Portscan
$target = "portquiz.net" $firstport = 1 $lastport = 65535 for($port=$firstport; $port -le $lastport; $port++) { Test-NetConnection -ComputerName $target -Port $port }
Useful Commandlets
Format-Hex $filename
ActiveDirectory Commandlets/Scripts
Groups / GroupMembers
$file="C:\Temp\GroupCount.csv" Get-ADGroup -Filter * -Properties Member ` | Select-Object Name,@{n="MemberCount";e={$_.Member.Count}} ` | Export-Csv -Path $file -Delimiter '|'
powershell.1668102253.txt.gz · Last modified: 2022/11/10 18:44 by baumi