Skip to content

Instantly share code, notes, and snippets.

View AspenForester's full-sized avatar

JB Lewis AspenForester

  • Hennepin County, MN, USA
  • Minnesota, USA
View GitHub Profile
@AspenForester
AspenForester / Show-ServerBootTime.ps1
Created May 16, 2014 16:12
Powershell to create a grid view of Server boot times. This is just a quick and dirty script (its really just a long one-liner), needs to be redeveloped into a more reusable tool.
# requires -version 3.0
$filter = {((name -notlike "*d") -and (name -notlike "*q")) -and ((name -notlike "dev*") -and (name -notlike "vdev*"))}
$SB = "OU=Servers,OU=Computers,OU=MyLocale,OU=MyDataCenterr,OU=NA,DC=foo,DC=local"
Get-ADComputer -filter $filter -SearchBase $SB -SearchScope Subtree |
where {(Test-Connection -ComputerName $_.name -Count 1 -Quiet)} |
% { Get-WmiObject -Class win32_operatingsystem -computername $_.name -Verbose} |
select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}} |
#Sort-Object -Property LastBootUpTime
Out-GridView -Title "Production Servers"
@AspenForester
AspenForester / Clear-ADGroupMember.ps1
Created May 16, 2014 16:36
A couple of quick functions for AD group maintenance
# requires version 3.0
<# Clear-ADGroupMember
.Synopsis
Removes all users from an AD group
.DESCRIPTION
Removes all users from an AD group provided to the script.
.EXAMPLE
“my-group” | Clear-ADGroupMember
#>
@AspenForester
AspenForester / event1.ps1
Created May 16, 2014 17:39
2013 PowerShell Scripting Games
{$_.Creationtime -lt (Get-Date).AddDays(-90)} |
ForEach-Object {
Move-Item -Force -Recurse -Path $_.FullName -Destination $($_.FullName.Replace("C:\Application\Log","\\NASServer\Archives"))
}
@AspenForester
AspenForester / Get-SummitSeats.ps1
Created November 1, 2016 21:14
Parses the HTML for the 2017 PowerShell Summit Eventloom page and returns the current number of available seats. It was written very as a think-type-do exercise. Show me you can do better!
$url = "https://eventloom.com/event/home/summit2017"
$page = Invoke-WebRequest -Uri $url
$outertext = $page.ParsedHtml.getElementsByTagName("div") | where Classname -eq "col-md-6" | Select -ExpandProperty OuterText
$AvailableText = ($outertext -split '[\r\n]').Where({$_ -like "*avail*"})
$SeatsAvailable = $AvailableText.Split(' ')[0]
Class PlayingCard {
[String] $Suit
[String] $FaceValue
hidden [int] $Value
PlayingCard (){}
PlayingCard ([String] $Suit, [String] $FaceValue){
$this.Suit = $Suit
$this.FaceValue = $FaceValue
@AspenForester
AspenForester / NBU8.cmd
Last active January 4, 2018 14:56
I usually run this remotely with psexec \\target -h -u domain\adminuser -c nbu8.cmd This is an improvement on the silent installer that comes with Netbackup. You need to add your org's info lines 16 and 23, plus create and point to a share on line 62 that at least contains the PC_Clnt\x64 directory from the install media.
@REM $Id: silentclient.cmd,v 1.24 2012/06/04 18:55:53 $
@ECHO -----------------------
@ECHO %COMPUTERNAME%
@DATE /T
@TIME /T
@ECHO -----------------------
@ECHO OFF
REM -------------------------------------------------------------------------------------------
SET CLIENT=%COMPUTERNAME%
@AspenForester
AspenForester / Get-PowerShellSummit2018AvailableSeats.ps1
Created January 4, 2018 19:08
Quick and dirty, should return the number of seats available for the 2018 PowerShell + DevOps Global Summit
$Foo = Invoke-WebRequest -Uri 'https://www.eventbrite.com/e/powershell-devops-global-summit-2018-registration-32452427083' -UseBasicParsing
$null = $foo -match 'remaining":(\d{1,3})'
$Matches[1]
@AspenForester
AspenForester / Compare-Things.ps1
Last active June 11, 2018 13:25
Compare one thing to a collection of wildcarded things
function Compare-Things
{
[CmdletBinding()]
[OutputType([bool])]
Param
(
# The singular thing that want to see if it matches
[Parameter(Mandatory=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
function Register-DNSVMGuest
{
#Requires -modules VMware.VimAutomation.Core,DNSClient
[CmdletBinding()]
param (
# Parameter help description
[Parameter(Mandatory = $true)]
[ValidateNotNullorEmpty]
[String]
$VIServer,
@AspenForester
AspenForester / Test-WSManAllServer.ps1
Created June 14, 2018 20:05
Tests for WSMan being enabled on one or more computers, and returns an object containing the computer name and a boolean value.
function Test-AllWSMANServer
{
[CmdletBinding()]
param (
# Computername
[Parameter(ValueFromPipeline = $true)]
[String[]]
$ComputerName
)