Skip to content

Instantly share code, notes, and snippets.

JB Lewis AspenForester

  • Hennepin County, MN, USA
Block or report user

Report or block AspenForester

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
AspenForester / IS2019-2.ps1
Created Jul 24, 2019
Iron Scripter 2019 - 2
View IS2019-2.ps1
$Measurement = get-childitem -Path C:\temp -Recurse -File | Measure-Object -Property Length -sum -Average
Count = $Measurement.Count
Average = $Measurement.Average
Sum = $Measurement.Sum
Date = Get-Date
ComputerName = $env:Computername
AspenForester / Get-LunarPhase.ps1
Created Oct 26, 2018
Gets the current local Lunar phased by assuming your location based on your public IP address, which isn't always accurate.
View Get-LunarPhase.ps1
$PublicIP = (Invoke-WebRequest -uri '' | convertfrom-json).ip
$GeoInfo = Invoke-WebRequest -Uri "$PublicIP" | ConvertFrom-Json
$location = "$($GeoInfo.geoplugin_latitude),$($GeoInfo.geoplugin_longitude)"
$TZ = [TimeZoneInfo]::Local.BaseUtcOffset.Hours
$Now = Get-date -Format M/dd/yyyy
AspenForester / Get-LongestSevenSegment.ps1
Last active Oct 12, 2018
Inspired by Tom Scott's Basics video on longest word you can create with a seven segment display. This version gets all of the longest, not just first of the longest and is lax on what letters count, allowing S and O. It also gets the word list from github, just in case any new words are invented.
View Get-LongestSevenSegment.ps1
$Words = (invoke-webrequest -uri -split ("`n")
<# Or If you have already downloaded the list
$Words = Get-Content -Path .\words_alpha.txt
[regex]$NonLetters = "[gkmqvwxyz]"
$LongestWords = @()
foreach ($Word in $Words)
AspenForester / Get-FileMetaData.ps1
Last active Aug 2, 2018
Returns one or more objects containing all 290 metadata items available for windows files.
View Get-FileMetaData.ps1
Gets all file metadata
Returns one or more objects containing all 290 metadata items available for windows files.
This function is based on work by Ed Wilson
PS C:\> Get-FileMetaData -Path c:\Users\Me\Documents
View FileServerShares.Tests.ps1
Describe "FileServer Shares" {
$FileServers = Import-PowerShellDataFile "H:\HennRepos\InfrastructureTesting\Diagnostics\simple\demodata.psd1"
Foreach ($Node in $FileServers.AllNodes)
Context "$($Node.NodeName)" {
# It might be desirable to ensure there is a DNS record for the server before even bothering to try and ping it
# I think I would still do the ping, let it fail and let that cause all of the share tests to be skipped.
$PingResult = Test-Connection -ComputerName $Node.NodeName -Quiet -Count 1
AspenForester / Restart-HungVM
Last active Jun 20, 2018
Used this to rapidly restart the VMs that got stuck rebooting after being patched. There may be other ways to get the list of machines to consider for restart other than a static list.
View Restart-HungVM
$vis = Connect-VIServer MyVcenter
$Servers = @("SomeServers")
foreach ($Server in $servers)
if ( -not (Test-NetConnection -ComputerName $Server -CommonTCPPort SMB).TcpTestSucceeded )
# Or maybe some other appropriate test or tests
get-vm $Server | Restart-VM -Confirm:$false
AspenForester / Enable-WSManRemote
Created Jun 14, 2018
Leverages PSexec to execute winrm quickconfig on machines that don't have WSMan enabled for remoting
View Enable-WSManRemote
function Enable-WSManRemote
[Parameter(Position = 0,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True)]
AspenForester / Test-WSManAllServer.ps1
Created Jun 14, 2018
Tests for WSMan being enabled on one or more computers, and returns an object containing the computer name and a boolean value.
View Test-WSManAllServer.ps1
function Test-AllWSMANServer
param (
# Computername
[Parameter(ValueFromPipeline = $true)]
View Register-DNSVMGuest.ps1
function Register-DNSVMGuest
#Requires -modules VMware.VimAutomation.Core,DNSClient
param (
# Parameter help description
[Parameter(Mandatory = $true)]
AspenForester / Compare-Things.ps1
Last active Jun 11, 2018
Compare one thing to a collection of wildcarded things
View Compare-Things.ps1
function Compare-Things
# The singular thing that want to see if it matches
You can’t perform that action at this time.