Skip to content

Instantly share code, notes, and snippets.

View Windos's full-sized avatar

Josh King Windos

View GitHub Profile
@Windos
Windos / Windos-ScriptingGames-2015-07
Created July 5, 2015 01:40
July 2015 Scripting Game Submissions, Windos
gwmi Win32_OperatingSystem -cn localhost | select PSC*, S*aj*, V*, @{N='BIOSSerial';E={(gwmi Win32_Bios -cn $_.__Server).SerialNumber}}
@Windos
Windos / SamAccountNameSpeed.ps1
Created September 30, 2015 01:56
It turns out there are a few different ways to search for a given SamAccountName ($user) using the Get-ADUser cmdlet. As part of a bigger project, I decided to find out which method was faster.
# Speeds are measured in milliseconds and are the average over 256 test runs
# 6.3 ms
Get-ADUser -Filter { SamAccountName -eq $user }
# 6.7 ms
Get-AdUser -LDAPFilter "(SamAccountName=$user)"
# 8.5 ms
Get-ADUser -Identity $user
@Windos
Windos / Windos-ScriptingGames-2015-10
Created October 16, 2015 10:04
October 2015 Scripting Game Submissions, Windos
function Get-RSSFeed
{
<#
.SYNOPSIS
Gets data from a RSS Feed.
.DESCRIPTION
The Get-RSSFeed function retrieves the title, link and excerpt from a specified rss feed.
Multiple URIs can be provided as parameters or piped to the function.
@Windos
Windos / Windos-ScriptingGames-2015-12.ps1
Last active December 7, 2015 22:50
December 2015 Scripting Games Submission, Windos
$list = @"
1 Partridge in a pear tree
2 Turtle Doves
3 French Hens
4 Calling Birds
5 Golden Rings
6 Geese a laying
7 Swans a swimming
8 Maids a milking
9 Ladies dancing
Verifying that +windos is my blockchain ID. https://onename.com/windos
@Windos
Windos / runOnOccurance.ps1
Created March 7, 2016 05:39
Simple logic to emulate running a script monthly.
# Set powershell job to run Weekly, on on the desired day.
# Wrap the code the job is running with the below so that it will only run
# when intended.
# e.g. Last Wednesday of month:
#
# $DayToRun = 'Wednesday'
# Occurance = -1
#
# The scheduled job still runs once a week, but will only execute your code
# if the date is validated.
@Windos
Windos / 2016-03-Beginner.ps1
Created March 12, 2016 02:56
Beginner entry for March 2016 PowerShell.org scripting games
# Beginner Puzzle
(Get-ChildItem C:\FileShare -Recurse).Where({$_.Name -match "[\u00C0-\u00FF]"}) |
Select-Object -Property Name,
Directory,
@{n="Creation Date";e={$_.CreationTime}},
@{n="Last Modification Date";e={$_.LastWriteTime}},
@{n="File Size";e={$_.Length}} |
Format-Table
@Windos
Windos / randomSelection.ps1
Created April 5, 2016 23:51
Random selection of Objects (Dumb and Smart)
# Dumb
$Count = ($ADComputer | Measure-Object).Count
$Random = Get-Random -Minimum 0 -Maximum $Count
$CandidateComputer = $ADComputer[$Random]
# Smart
$CandidateComputer = Get-Random -InputObject $ADComputer
@Windos
Windos / Windos-ScriptingGames-2016-05.ps1
Created April 27, 2016 08:44
May 2016 Scripting Games Submission, Windos
$Group = Read-Host -Prompt 'Specify problem group'
Get-AdGroupMember -Identity $Group -Recursive |
Where-Object -FilterScript {$_.objectClass -eq 'user'} |
Get-AdUser -Properties 'EmailAddress', 'Department' |
Select-Object 'Name', 'EmailAddress', 'Department'
<#
Assumptions:
* Execution policy configured so this can run
* Person running this has proper access to Active Directory
@Windos
Windos / PuTTY-Theme-Grabber.ps1
Last active November 1, 2016 01:16
Lunch hours effort in downloading then converting PuTTY themes into a standard JSON format
$ThemeLists = 'http://putty.org.ru/themes/index.html', 'http://putty.org.ru/themes/page2.html', 'http://putty.org.ru/themes/page3.html', 'http://putty.org.ru/themes/page4.html', 'http://putty.org.ru/themes/page5.html'
foreach ($Uri in $ThemeLists)
{
$Content = Invoke-WebRequest -Uri $Uri
$List = $Content.ParsedHtml.getElementsByTagName('ol')
$Links = $List[0] | foreach {$_.getElementsByTagName('a') | where {$_.textContent -ne $null} }
foreach ($Link in $Links)
{