User Tools

Site Tools


powershell

This is an old revision of the document!


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"
for($i=1; $i -le 65535; $i++) {
  Test-NetConnection -ComputerName $target -Port $i
}

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.1668102164.txt.gz · Last modified: 2022/11/10 18:42 by baumi

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki