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 | |
Registers a HTTP prefix and listens for a HttpRequest | |
.DESCRIPTION | |
Simple PowerShell HTTP Server implementation to respond to a single HTTP request | |
.EXAMPLE | |
Get-HttpRequest -UriPrefix "http://+:80/TestUri/" -ResponseData (Get-Content C:\inetpub\wwwroot\index.html) | |
.EXAMPLE | |
Get-HttpRequest -UriPrefix "http://127.0.0.1/" -ResponseData "It Works...!" -ShowRequest | |
#> |
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
param($u)(&{if($c-is[System.Net.WebClient]){$c}else{($global:c=New-Object System.Net.WebClient)}}).DownloadString($u) |
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
gci "\\$(($d=$env:USERDNSDOMAIN))\sysvol\$d\Policies"|?{$_.Name-imatch"^(?<g>\{[A-F\d]{8}(-[A-F\d]{4}){3}-[A-F\d]{12}\})$"}|?{[ADSI]::Exists("LDAP://CN=$($Matches["g"]),CN=Policies,CN=System,DC=$($d-split"\."-join",DC=")")}|%{"{0} is an orphan, remove it"-f$_.FullName} |
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 Get-MachineSID | |
{ | |
param( | |
[switch] | |
$DomainSID | |
) | |
# Retrieve the Win32_ComputerSystem class and determine if machine is a Domain Controller | |
$WmiComputerSystem = Get-WmiObject -Class Win32_ComputerSystem | |
$IsDomainController = $WmiComputerSystem.DomainRole -ge 4 |
OlderNewer