Skip to content

Instantly share code, notes, and snippets.

View randomchance's full-sized avatar

Chance Carroll randomchance

View GitHub Profile
# sleepy flower girl
(◡ ‿ ◡ ✿)
# y u no
ლ(ಠ益ಠლ)
# smiling breasts
(^人^)
# flipping tables
@randomchance
randomchance / Resolve-Fullpath.ps1
Created August 15, 2019 14:33
powershell function to resolve a file path, expanding any mapped dives to their full UNC path in the process.
function Resolve-FullPath
{
[CmdletBinding()]
[OutputType([string])]
param (
# The Path to the File or Folder
[Parameter(Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[Alias("FullName")]
[ValidateNotNullOrEmpty()]
@randomchance
randomchance / Assert-All.ps1
Created August 18, 2016 20:50
Simple ANY and ALL functions for PowerShell.
<#
.SYNOPSIS
Assert-All returns true if EVERY object in the pipeline evaluates to true.
.DESCRIPTION
Assert-All returns true if every item in the pipeline evaluates to true.
Assert-All will not return until the entire pipeline has been processed.
@randomchance
randomchance / Get-DrinkingWaterStudyData.ps1
Last active September 9, 2019 01:52
Finding local data from the massive dump of water quality studies referenced in this [article](https://www.hsph.harvard.edu/news/press-releases/toxic-chemicals-drinking-water/)
# There are lots of "one-liner" scripts out to grab this data, but this isn't one
# this is broken apart to make it easier to follow along with and adjust as needed
# download raw data at https://www.epa.gov/sites/production/files/2015-09/ucmr-3-occurrence-data.zip
# extract it and update the two paths below, or just run this from the extracted directory.
$zipFile ="UCMR3_ZipCodes.txt"
$AllFile = "UCMR3_All.txt"
# replace these zip codes with ones you are interested in
[string[]] $ZipCodes = @('48103','28401')
@randomchance
randomchance / Get-WindowsUpdateStatus.ps1
Last active August 18, 2016 21:45
Query computers for windows update status. Now writes out warnings for computers needing patches.
<#
.EXAMPLE
Get-WindowsUpdateStatus -ComputerName ('Server01.test.local,'Server02.test.local')
ComputerName HasPendingUpdates Updates
------------ ----------------- -------
Server01 False {}
Server01 False {}
$Computers = (Get-ADComputer -Filter {Name -like '*'}).DNSHostName
$TestedPath = "C:\Program Files\Git" # this is the example path I am checking for.
if(-not $Credential ){
$Credential = Get-Credential
}
Write-Verbose "Determining which computers can be reached, this may take a long time depending on your environment." -Verbose
[string[]] $reachableComputers = $Computers | where {Test-Connection -ComputerName $_ -Quiet -Count 1}
@randomchance
randomchance / prompt.ps1
Last active April 6, 2020 08:03 — forked from kadet1090/prompt.ps1
PowerLine like prompt for PowerShell
$script:bg = [Console]::BackgroundColor;
$script:first = $true;
$script:last = 0;
Import-Module Posh-Git
$BranchBehindAndAheadStatusForegroundColor = [System.ConsoleColor]::Magenta
$BranchBehindStatusForegroundColor = [System.ConsoleColor]::Yellow
$BranchAheadStatusForegroundColor = [System.ConsoleColor]::Green
$BranchIdenticalStatusToForegroundColor = [System.ConsoleColor]::White
$workingAdded = '+'