Skip to content

Instantly share code, notes, and snippets.

Mathias R. Jessen IISResetMe

  • Booking.com
  • Netherlands
Block or report user

Report or block IISResetMe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@IISResetMe
IISResetMe / Search-Filename.ps1
Created Oct 7, 2014
Speedy PowerShell file search on Windows
View Search-Filename.ps1
<#
.Synopsis
Performs a basic filename search throughout a directory
.DESCRIPTION
Performs a basic filename search throughout a directory and returns matching file names
.EXAMPLE
Search-Filename -Path "C:\Windows\System32" -Pattern "*.dll"
.EXAMPLE
Search-Filename "document.txt" -Recurse
#>
@IISResetMe
IISResetMe / Get-TorExitNodes.ps1
Created Oct 8, 2014
Gather known Tor Exit node IP adresses, useful for traffic blacklisting
View Get-TorExitNodes.ps1
$TempFile = [System.IO.Path]::GetTempFileName()
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile("https://check.torproject.org/exit-addresses",$TempFile)
$WebClient.Dispose()
$ExitNodes = Get-Content $TempFile |? {$_ -match "^ExitAddress\b"}
Remove-Item $TempFile -Force
$IPAddr = $ExitNodes |% {($_ -split " ")[1]}
@IISResetMe
IISResetMe / map.ps1
Created Oct 9, 2014
Implementing map function in PowerShell
View map.ps1
function map
{
param(
[Parameter(Mandatory=$true,Position=0)]
[scriptblock]
$Function,
[Parameter(Mandatory=$true,Position=1)]
[Object[]]
$InputObject
)
@IISResetMe
IISResetMe / Repair-XmlString.ps1
Last active Aug 29, 2015
Sanitizes your XML input!
View Repair-XmlString.ps1
function Repair-XmlString
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,Position=0)]
[string]$inXML
)
# Match all characters that does NOT belong in an XML document
$rPattern = "[^\x09\x0A\x0D\x20-\xD7FF\xE000-\xFFFD\x10000\x10FFFF]"
@IISResetMe
IISResetMe / healthcheck.ps1
Last active Aug 29, 2015
Domain vs Forest in Jeff's AD health check
View healthcheck.ps1
param(
...
[Parameter(Mandatory=$false,ParameterSetName='Specific')]
[Parameter(Mandatory=$false,ParameterSetName='All')]
[Switch]$EntireForest
)
function Get-ADDomains {
if($EntireForest)
{
@IISResetMe
IISResetMe / Split-DN.ps1
Created Dec 22, 2014
Leverage the power of RegEx!
View Split-DN.ps1
# Negative lookbehind
function Split-DN{
param([String]$DN)
return $DN-split"(?<!\\),"
}
# Positive lookbehind with negative expression
function Split-DN{
param([String]$DN)
return $DN-split"(?<=[^\\]),"
View Logging_Functions.ps1
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
@IISResetMe
IISResetMe / MySnippets.ps1
Created Apr 24, 2015
Must-have custom ISE snippets
View MySnippets.ps1
New-IseSnippet -Title '@Calculated Property, Named' -Description "Named calculated property template" -Text '@{ Name = ""; Expression = { } }' -CaretOffset 11
New-IseSnippet -Title '@Calculated Property, Anonymous' -Description "Calculated property template, without a name (For use with Sort-Object and Group-Object)" -Text '@{ Expression = { } }' -CaretOffset 18
@IISResetMe
IISResetMe / passfunc.ps1
Last active Aug 29, 2015
Pass function as argument in PowerShell
View passfunc.ps1
function Reverse-String {
param(
[string]$instr
)
$chars = $instr.ToCharArray()
[array]::Reverse($chars)
$chars -join ""
}
View New-JunkFile
function New-JunkFile
{
<#
.SYNOPSIS
Generates a file of a specified length, filled with random bytes
.DESCRIPTION
Generates a file of a specified length, filled with random bytes
Uses the RNGCryptoServiceProvider to randomly select each byte
You can’t perform that action at this time.