Skip to content

Instantly share code, notes, and snippets.

@mortenya
mortenya / Parse-DHCPLog.ps1
Last active August 29, 2015 14:08
This scripts takes a DHCP Log as input, and then parses it for unique Devices that requested a lease, Event ID 10.
Function Get-FileName($initialDirectory) {
Add-Type -Assembly System.windows.forms | Out-Null
$initialDirectory = "C:\"
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.InitialDirectory = $initialDirectory
$OpenFileDialog.Filter = "Log files (*.Log)| DhcpSrvLog-*.log"
$OpenFileDialog.Multiselect = $false
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.FileName
} #end function Get-FileName
function Get-MappedDrives {
<#
.Synopsis
Returns the Mapped Drives on the system
.DESCRIPTION
This function uses WMI to query computers on the network and return the mapped drives, not local drives.
If no user is logged on there will likely be an error about RPC server not available.
.PARAMETER ComputerName
The name of the system(s) you want to check
.EXAMPLE
@mortenya
mortenya / 01-inputs.conf
Last active September 14, 2017 02:07
I have this taking events from my Snort Defense Center, it's light right now, mostly a proof of concept.
input {
syslog {
port => 1514
}
}
filter {
#IP Address of Snort
if [host] =~ /192\.168\.0\.250/ {
mutate {
@mortenya
mortenya / CustomModule.psm1
Last active August 29, 2015 14:02
Originally written by Boe Prox, when loading a custom module this will source any scripts in the $ModulePath\Scripts folder, as well as check if you've loaded PowerShell as an Administrator.
#Validate user is an Administrator
Write-Verbose "Checking Administrator credentials"
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You are not running this as an Administrator!`nPlease re-run module with an Administrator Account."
Break
}
#Load Functions
$ScriptPath = Split-Path $MyInvocation.MyCommand.Path
Try {
Function Get-SharedFolderACL {
<#
.Synopsis
Recursively steps through folders and collects the Access Control List
.DESCRIPTION
Run the cmdlet against one or more Mapped Drives or Shares and it will create a .txt file with the ACLs of every folder in the structure
If you are getting the ACL from a share with many nested folders then it will take a significant amount of time to run
and the resulting .txt files can be quite large
.PARAMETER Shares