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
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
[pscustomobject]@{
Count = $Measurement.Count
Average = $Measurement.Average
Sum = $Measurement.Sum
Date = Get-Date
ComputerName = $env:Computername
}
@AspenForester
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 'https://api.ipify.org?format=json' | convertfrom-json).ip
$GeoInfo = Invoke-WebRequest -Uri "http://www.geoplugin.net/json.gp?ip=$PublicIP" | ConvertFrom-Json
$location = "$($GeoInfo.geoplugin_latitude),$($GeoInfo.geoplugin_longitude)"
$TZ = [TimeZoneInfo]::Local.BaseUtcOffset.Hours
$Now = Get-date -Format M/dd/yyyy
@AspenForester
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 https://raw.githubusercontent.com/dwyl/english-words/master/words_alpha.txt).content -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
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
<#
.Synopsis
Gets all file metadata
.DESCRIPTION
Returns one or more objects containing all 290 metadata items available for windows files.
This function is based on work by Ed Wilson
https://gallery.technet.microsoft.com/scriptcenter/c3d0ea6c-64a1-4716-a262-bcd71c9925fc#content
https://blogs.technet.microsoft.com/heyscriptingguy/2009/12/29/hey-scripting-guy-how-can-i-list-all-the-properties-of-a-microsoft-word-document/
.EXAMPLE
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
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
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
{
[cmdletbinding()]
Param(
[Parameter(Position = 0,
ValueFromPipeline = $True,
ValueFromPipelineByPropertyName = $True)]
[ValidateNotNullorEmpty()]
[string[]]
@AspenForester
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
{
[CmdletBinding()]
param (
# Computername
[Parameter(ValueFromPipeline = $true)]
[String[]]
$ComputerName
)
View Register-DNSVMGuest.ps1
function Register-DNSVMGuest
{
#Requires -modules VMware.VimAutomation.Core,DNSClient
[CmdletBinding()]
param (
# Parameter help description
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty]
[String]
$VIServer,
@AspenForester
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
{
[CmdletBinding()]
[OutputType([bool])]
Param
(
# The singular thing that want to see if it matches
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
You can’t perform that action at this time.