Skip to content

Instantly share code, notes, and snippets.

## Get-LinkTarget.ps1
# Note: Script should be symlinked as follows:
# Get-LinkTarget.ps1 -> Resolve-UNCPath.ps1
# Get-LinkTarget.ps1 -> Resolve-JunctionPath.ps1
# Get-LinkTarget.ps1 -> Resolve-HardlinkPath.ps1
# Get-LinkTarget.ps1 -> Resolve-SymlinkPath.ps1
# Get-LinkTarget.ps1 -> Resolve-ReparsePointPath.ps1
function Global:Get_UNCPath($l_dir)
{
<#
.SYNOPSIS
Copies Windows Spotlight images from ContentDeliverManager cache folder to "Pictures" folder.
.DESCRIPTION
Copies all images larger than 50KB from Windows Spotlight cache folder to \Pictures\Backgrounds\Spotlight,
creating destination directory if it does not exist.
.NOTES
Requires Lock Screen Background set to "Windows Spotlight" (Start-Process ms-settings:lockscreen).
Spotlight cache folder will populate over time, with new images usually added several times per week.
Caveat: Windows Store also stores images in the same dir, some may be mistaken as a spotlight images.
@Trucido
Trucido / promptstuff.ps1
Last active March 18, 2019 23:54
posh prompt nonsense
############################################################################################################################################
## Prompt ##
############################################################################################################################################
Clear-Host
[ScriptBlock]$Prompt = {
$origLastExitCode = $global:LASTEXITCODE
Set-StrictMode -Version 'Latest'
$gitLoaded = $false # skip stupid git module, adds ~1000ms to startup time.
<#PSScriptInfo
.NAME Get-FileFromUri.ps1
.VERSION 1.0
.GUID 5c779f0b-6db9-43bd-a0c0-246125f9c7e9
.TAGS Get-FileFromUri PSWget wget WebRequest WebClient Invoke-WebRequest
#>
<#
.SYNOPSIS
Retrieves remote content to the current directory or OutFile path.
function which2 {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true,ValueFromPipeline=$true)]
$Name
)
$ErrorActionPreference = 'Stop'
try {
[object]$getCommand = Get-Command $Name
@Trucido
Trucido / Invoke-WmiMonitorBrightness.ps1
Last active March 16, 2019 07:30
Stupid wmi backlight control script
<#
Invoke-WmiMonitorBrightness.ps1 - Backlight control for screen brightness (Note: Does not work with ALS enabled)
#>
function Invoke-WmiMonitorBrightness() {
Set-StrictMode -Version Latest
[scriptblock] $GetMonitorBrightness = {
(Get-Ciminstance -Namespace ROOT/wmi -ClassName WmiMonitorBrightness).CurrentBrightness
}
@Trucido
Trucido / 50-coredump.conf
Last active March 16, 2019 00:45
Disable systemd dumps
# /etc/sysctl.d/50-coredump.conf
##################################################################################
## NO DUMPING ALLOWED ##
## VIOLATORS WILL BE PROSECUTED ##
##################################################################################
fs.suid_dumpable = 0
kernel.suid_dumpable = 0
kernel.core_pattern = |/bin/false
<#
volume.ps1 - Get/Set IAudioEndpointVolume
Note: Get-Volume/Set-Volume conflicts with Storage\MSFT_Volume
#>
function GetSet-Volume {
Param(
[Parameter(mandatory=$false)] [float] [ValidateRange(0.000,1.000)] $Value,
[Alias("M*","U*")] [switch] $Mute
)
## File: Get-FileAttributesEx.ps1
<#
.SYNOPSIS
Lists NTFS file or folder attributes and flags.
.DESCRIPTION
Lists many undocumented or otherwise inaccessible file attributes and flags.
.PARAMETER Path
Path to file(s)/folder(s) to list properties. Wildcards and hidden or system files are supported.
.INPUTS System.Management.Automation.PathInfo, System.String
You can pipe PathInfo objects or strings that contain paths to this cmdlet.
<#
Get-Clipboard.ps1 - Gets clipboard content if content type is text.
Note: Conflicts/replaces Pscx\Get-Clipboard which doesn't work in powershell >= 6
#>
function Get-ClipboardText([switch][Alias("S*","L*")]$SplitLF) {
Set-StrictMode -Version 'Latest'
if($SplitLF) {
# Note: Newline CRLF/CR/LF handling should be automatic, but just in case...
$cmd = {
Add-Type -Assembly PresentationCore