This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.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 | |
#> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function map | |
{ | |
param( | |
[Parameter(Mandatory=$true,Position=0)] | |
[scriptblock] | |
$Function, | |
[Parameter(Mandatory=$true,Position=1)] | |
[Object[]] | |
$InputObject | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
... | |
[Parameter(Mandatory=$false,ParameterSetName='Specific')] | |
[Parameter(Mandatory=$false,ParameterSetName='All')] | |
[Switch]$EntireForest | |
) | |
function Get-ADDomains { | |
if($EntireForest) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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"(?<=[^\\])," |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Ping-Forever.ps1 | |
# | |
# Modified version of alexinnes/ConstantPingToServer.ps1 (https://gist.github.com/alexinnes/b2076c88700020af3963) | |
# | |
[CmdletBinding()] | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$ComputerName, | |
[string]$LogDirectory = 'C:\ping logs\' |
OlderNewer