This file contains hidden or 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-HtmlContent { | |
[CmdletBinding()] | |
[alias('ghc')] | |
param ( | |
[Parameter(ValueFromPipeLine, Mandatory)] | |
[Uri[]]$Uri, | |
[string]$UserAgent, | |
[switch]$NoEncoding | |
) | |
begin { |
This file contains hidden or 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 Slice-String ([string]$string, [int]$length, [int[]]$part) { | |
if ($length -gt 1) { | |
if ($part.count) { | |
($string -split "(?<=.)(?=(?:.{$length})+$)")[$part] | |
} else { | |
$string -split "(?<=.)(?=(?:.{$length})+$)" | |
} | |
} else {$string} | |
} |
This file contains hidden or 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 Invoke-PSCommand { | |
[CmdletBinding(DefaultParameterSetName='scriptblock')] | |
[alias('ipsc')] | |
param ( | |
[Parameter(Mandatory,Position=0,ParameterSetName='scriptblock')] | |
[ValidateNotNullOrEmpty()] | |
[alias('sb')][ScriptBlock] $ScriptBlock, | |
[Parameter(Mandatory,Position=0,ParameterSetName='file')] | |
[ValidateNotNullOrEmpty()] | |
[alias('fn')][string] $FileName, |
This file contains hidden or 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
"C:\ProgramData\Microsoft\Windows\Start Menu\*.lnk", | |
"$($ENV:APPDATA)\Microsoft\Windows\Start Menu\Programs\*.lnk" | | |
Get-ChildItem -Recurse | ForEach-Object { | |
[PSCustomObject]@{ | |
Name = $_.baseName | |
Shortcut = $_.Fullname | |
} | |
} | Sort-Object Name |
This file contains hidden or 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 Convert-EventLogRecord { | |
[cmdletbinding()] | |
[alias('clr','Format-EventLogRecord')] | |
param ( | |
[Parameter(Position=0,Mandatory,ValueFromPipeline)] | |
[ValidateNotNullOrEmpty()] | |
[alias('logrecord','events')] | |
[System.Diagnostics.Eventing.Reader.EventLogRecord[]]$InputObject | |
) |
This file contains hidden or 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 Use-Culture { | |
param ( | |
[System.Globalization.CultureInfo]$culture = (throw "USAGE: Use-Culture -Culture culture -Script {scriptblock}"), | |
[ScriptBlock]$script = (throw "USAGE: Use-Culture -Culture culture -Script {scriptblock}") | |
) | |
$OldCulture = [System.Threading.Thread]::CurrentThread.CurrentCulture | |
trap { | |
[System.Threading.Thread]::CurrentThread.CurrentCulture = $OldCulture | |
} | |
[System.Threading.Thread]::CurrentThread.CurrentCulture = $culture |
This file contains hidden or 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
<# | |
Inspired by Doug Finke's map function | |
https://dfinke.github.io/search%20engines/2024/11/13/Introducing-a-Custom-map-Function-in-PowerShell-for-Functional-Programming.html | |
#> | |
function Convert-Object { | |
[CmdletBinding()] | |
[alias('map')] | |
param ( | |
[Parameter(Mandatory)] | |
$func, |
This file contains hidden or 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 | |
NIC Team default macaddress setter. | |
.DESCRIPTION | |
When using DHCP reservation for NIC teaming in Windows Server there is no way of determining which member interface becomes primary at boot. Because it is impossible to determine this, we do not know which member's MAC address will be used by the team. This makes DHCP troublesome. | |
#> | |
param ( | |
[alias('name')][string]$teamname, | |
[string]$macaddress, | |
[alias('apply')][switch]$run |
This file contains hidden or 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 | |
VMware Tools Remover | |
.DESCRIPTION | |
This script will automatically rip out all VMware Tools registry entries, | |
files, drivers, DLLs, and services for Windows 7-11, 2008-2022. | |
Features: | |
- View/Action modes |
This file contains hidden or 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 compress-range ([int[]]$inputobject, [switch]$sort, [switch]$unique) { | |
if (-not $inputobject.count) {return} | |
$first = $true | |
$range = $inputobject[0],$inputobject[0] | |
$param = @{} | |
if ($unique) {$param['unique'] = $true} | |
$sb = if ($sort) {{$inputobject | Sort-Object @param}} else {{$inputobject}} | |
foreach ($e in (.$sb)) { | |
$diff = [math]::Abs($e - $range[1]) | |
if ($diff -eq 1) {$range[1]++} |
NewerOlder