Skip to content

Instantly share code, notes, and snippets.

View 9to5IT's full-sized avatar

9to5IT 9to5IT

View GitHub Profile
@9to5IT
9to5IT / Logging_Functions.ps1
Last active March 20, 2023 00:47
PowerShell: Logging Functions
Function Log-Start{
<#
.SYNOPSIS
Creates log file
.DESCRIPTION
Creates log file with path and name that is passed. Checks if log file exists, and if it does deletes it and creates a new one.
Once created, writes initial logging data
.PARAMETER LogPath
@9to5IT
9to5IT / Get-AccountLockouts.ps1
Last active August 16, 2021 12:52
PowerShell: Get-WinEvent to find Account Lockout Events
#requires -version 2
<#
.SYNOPSIS
Lists date, time and machine name where the specified account was locked. Used for troubleshooting account lockout issues.
.DESCRIPTION
This script outputs to specified file all of the recent account lockouts that have occurred for the specified user. The results returned are the machine name where this has occurred and the data & time it occurred at. This script is very useful for troubleshooting account lockout issues.
Note: This script only searches current security logs on the domain controllers specified within the $DCs variable
@9to5IT
9to5IT / Get-PrintedDocs.ps1
Last active December 13, 2021 14:15
PowerShell: Get list of printed documents
$aPrinterList = @()
$StartTime = "11/01/2013 12:00:01 PM"
$EndTime = "11/01/2013 6:00:01 PM"
$Results = Get-WinEvent -FilterHashTable @{LogName="Microsoft-Windows-PrintService/Operational"; ID=307; StartTime=$StartTime; EndTime=$EndTime;} -ComputerName "print-01"
ForEach($Result in $Results){
$ProperyData = [xml]$Result.ToXml()
$PrinterName = $ProperyData.Event.UserData.DocumentPrinted.Param5