Windows/PowerShell/Common Tools

From r00tedvw.com wiki
Jump to: navigation, search

Below are some common tools for Powershell 7 Core with a focus on system administration.

Contents

 [hide

Show open ports

PS /> Get-NetTCPConnection
PS /> Get-NetTCPConnection | Where-Object { $_.State -eq 'Listen' }

Process List

PS /> Get-Process
PS /> Get-Process | Sort-Object CPU -Descending | Format-Table -Property Name, CPU, Id, MemoryUsage -AutoSize
PS /> while ($true) { Get-Process | Sort-Object CPU -Descending | Format-Table -Property Name, CPU, Id, MemoryUsage -AutoSize; Start-Sleep -Seconds 1 }

Disk Space

PS /> Get-PSDrive -PSProvider FileSystem
PS /> Get-Volume

CPU Usage

PS /> Get-Counter -Counter "\Processor(_Total)\% Processor Time"
PS /> Get-Counter -Counter "\Processor(_Total)\% Processor Time" -Continuous

Network Utilization

PS /> Get-NetAdapterStatistics
PS /> Get-Counter -Counter "\Network Interface(*)\Bytes Total/sec"
PS /> Get-Counter -Counter "\Network Interface(*)\Bytes Total/sec" -Continuous

Uptime

PS /> $uptime = (Get-Date) - (Get-CimInstance -ClassName Win32_OperatingSystem).LastBootUpTime
PS />$uptime

Memory Usage

PS /> Get-PhysicalMemory
PS /> Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object TotalVisibleMemorySize, FreePhysicalMemory

List Installed Software

PS /> Get-CimInstance -ClassName Win32_Product | Select-Object Name, Version
PS /> Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion

Check System Updates

PS /> Install-Module -Name PSWindowsUpdate -Force -SkipPublisherCheck
PS /> Get-WindowsUpdate

Get System Info

PS /> Get-ComputerInfo
PS /> (Get-ComputerInfo).OsArchitecture

Check Active Users Sessions

PS /> quser

Show Event Logs

PS /> Get-EventLog -LogName System -Newest 10

List Scheduled Tasks

PS /> Get-ScheduledTask
Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki