Scans the defined network range using an ARP scan to identify hosts on the network.  For all found hosts the MAC address is checked against a text file known_hosts.txt for a match.  If it is found the description is displayed and the host is identified.  If the MAC address is not found, an email is sent to the configured email address and the MAC address, IP address and time is logged to the file unknown_hosts.txt.  The script repeats the scans at the configured interval.

Screen Shots

All hosts detected:

ARP Scan - All Hosts Recognised

Rogue host detected:

Rogue Host Detected

More »

This is my PowerShell log file parser with email alert – it’s a bit rough, could do with some optimizing, but a quick overview – it searches for the text string ‘warn’ or ‘error’.

You will need to adjust the structure of the log files and folder to make them suit your application, and you must set the SMTP settings towards the bottom of the script: More »

Get date of when the password was last set (converts date of PwdLastSet from 8 bti integer to readable form), and lists how many bad logon attempts there have been.  Make sure you are using the PowerShell with Active Directory Module (Start, Administrative Tools, Active Directory Module for Windows Powershell, issue an ‘import-module activedirectory’ from a plain PowerShell prompt) :
get-ADuser -filter {(ObjectClass -eq "user")} -Properties * | FT Name, PasswordLastSet, BadPwdCount

We can add a sort to help identify old passwords:

get-ADuser -filter {(ObjectClass -eq "user")} -Properties * | sort PasswordLastSet -descending | FT Name, PasswordLastSet, BadPwdCount
Of course we could also use dsquery, but it doesn’t offer as much flexibility:

dsquery * -filter "&(objectClass=person)(objectCategory=user)" -attr cn badPwdCount

A quck reference for some common commands:

Export to PST

Export-Mailbox –Identity <mailboxUser> -PSTFolderPath <pathToSavePST>

Mailbox Size

Get-MailboxStatistics | ft displayname,totalitemsize,lastlogontime

Mailbox Size – Sorted by Size Descending

Get-MailboxStatistics | Sort-Object -Descending TotalItemSize | ft displayname,totalitemsize,lastlogontime

Create a new mailbox-enabled user
new-Mailbox -alias testmbx -name TestMailbox -database “Mailbox Database” -org Users -UserPrincipalName
Password: <userpassword>
Create a new resource mailbox (Conference Room or Equipment)
New-Mailbox -alias testresmbx -name TestResourceMailbox -database “Mailbox Database” -org Users <-Room | -Equipment>  -UserPrincipalName

Create a shared mailbox
new-Mailbox -alias testsharedmbx -name TestSharedMailbox -database “Mailbox Database” -org Users -shared -UserPrincipalName

Create a new linked mailbox
New-Mailbox -alias testlinkedmbx -name TestLinkedMailbox -database “Mailbox Database” -org Users -LinkedMasterAccount -LinkedDomainController userdomain-dc-01 -UserPrincipalName

Mail-enable an existing user as a user mailbox
Enable-Mailbox logondisableduser -database “Mailbox Database”

Mail-enable an existing (AD logon-disabled) user as a resource mailbox (Conference Room or Equipment)
Enable-Mailbox logondisableduser <-Room | -Equipment> -database “Mailbox Database”

Mail-enable an existing (AD logon-disabled) user as a linked mailbox
Enable-Mailbox logondisableduser -database “Mailbox Database” -LinkedMasterAccount -LinkedDomainController userdomain-dc-01

Move an individual mailbox
Move-Mailbox testmbx -targetdatabase “Mailbox Database”

Move all mailboxes stored on a server to a target mailbox database
Get-Mailbox -server testserver | Move-Mailbox -targetdatabase “Mailbox Database”

Disable one individual mailbox
Disable-Mailbox testmbx

Disable all mailboxes stored on a server
Get-Mailbox -server testserver | Disable-Mailbox

Remove one individual mailbox-enabled user
Remove-Mailbox testmbx

Remove all mailbox-enabled users stored on a server
Get-Mailbox -server testserver | Remove-Mailbox

Set storage quotas
Set-Mailbox testmbx -UseDatabaseQuotaDefaults:$False -IssueWarningQuota 90MB -ProhibitSendQuota 95MB -ProhibitSendReceiveQuota 100MB

Set a mailbox to forward mail to another recipient and recipients limits
Set-Mailbox testmbx -DeliverToMailboxAndForward:$True -ForwardingAddress -RecipientLimits 10

Grant “Send on behalf” permission
Set-Mailbox testmbx -GrantSendOnBehalfTo jaredz

Grant “Send-As” permission
Add-ADPermission testmbx -ExtendedRights Send-As -user jaredz

Grant full mailbox access permission
Add-MailboxPermission testmbx -AccessRights FullAccess -user jaredz

Get Log Files Paths

Get-StorageGroup -server <servername>| fl *path*

Mailbox Database Path

Get-MailboxDatabase -server <servername>| fl *path*

Public Folder Database

Get-PublicFolderDatabase -server <servername>| fl *path*

Log Paths

Get-MailboxServer <servername>| fl *path*