PowerShell Dump DHCP Reservations

A script to dump all of the reservations from a Windows DHCP server

$PropArray = @()
$scopes = Get-DhcpServerv4Scope -ComputerName dhcpprd01

foreach ($scope in $scopes)
    {    
    $Reservations = Get-DhcpServerv4Reservation -ComputerName dhcpprd01 -ScopeId $scope.ScopeId
    foreach ($Reservation in $Reservations)
        {
        $Prop = New-Object System.Object
        $Prop | Add-Member -type NoteProperty -name ScopeID -value $Reservation.ScopeID
        $Prop | Add-Member -type NoteProperty -name IpAddress -value $Reservation.IPAddress
        $Prop | Add-Member -type NoteProperty -name ClientID -value $Reservation.ClientID
        $Prop | Add-Member -type NoteProperty -name Name -value $Reservation.Name
        $Prop | Add-Member -type NoteProperty -name Type -value $Reservation.Type
        $PropArray += $Prop
       
        }
    }
$PropArray | ft -AutoSize

PowerShell Dump DHCP Leases

Dump all of the DHCP leases from a Windows DHCP server into an object using PowerShell

$PropArray = @()
$scopes = Get-DhcpServerv4Scope -ComputerName dhcpprd01

foreach ($scope in $scopes)
    {    
    $Leases = Get-DhcpServerv4Lease -ComputerName dhcpprd01 -ScopeId $scope.ScopeId
    foreach ($Lease in $Leases)
        {
        $Prop = New-Object System.Object
        $Prop | Add-Member -type NoteProperty -name ScopeID -value $Lease.ScopeID
        $Prop | Add-Member -type NoteProperty -name IpAddress -value $Lease.IPAddress
        $Prop | Add-Member -type NoteProperty -name ClientID -value $Lease.ClientID
        $Prop | Add-Member -type NoteProperty -name HostName -value $Lease.HostName
        $Prop | Add-Member -type NoteProperty -name AddressState -value $Lease.AddressState
        $PropArray += $Prop
        }
    }

$PropArray

Get Log Entries For a Range of Time on Linux

You need to check the logs for a problem and you know when it occurred. This will allow you to grab all of the entries for a period of time to make the search for clues easier.

sudo cat secure | awk '/^Dec  1 09:27/,/^Dec  1 09:33/'
Dec  1 09:03:09 u16532612 sshd[24297]: Failed password for root from 43.229.53.54 port 43335 ssh2
Dec  1 09:03:12 u16532612 sshd[24297]: Failed password for root from 43.229.53.54 port 43335 ssh2
Dec  1 09:03:14 u16532612 sshd[24297]: Failed password for root from 43.229.53.54 port 43335 ssh2