Skip to content

Instantly share code, notes, and snippets.

View Jaykul's full-sized avatar
😀
Learning

Joel Bennett Jaykul

😀
Learning
View GitHub Profile
@Jaykul
Jaykul / Install-LegacyFirefox.ps1
Created February 21, 2017 00:05
How to install a specific version of Firefox and make sure it doesn't get updated
# NOTE: Hard-coded to 64bit, default install, MaintenanceService off
$FFxVersion = '44.0'
$locale = 'en-US'
$Downloads = Convert-Path $Home\Downloads
$IsoPath = Join-Path $Downloads agent.iso
$FFxPath = Join-Path $Downloads ffx.exe
$ProgressPreference = "SilentlyContinue"
Invoke-WebRequest "https://download.mozilla.org/?product=firefox-${FFxversion}-SSL&os=win64&lang=${locale}" -Outfile $FFxPath
@Jaykul
Jaykul / Ribbon.psd1
Created January 30, 2014 08:20
Ribbon Window in PowerShell (#requires ShowUI)
## AutoGenerated file. Do Not Edit. Regenerate by running
## Add-UIModule -AssemblyName System.Windows.Controls.Ribbon -Name Ribbon
@{
ModuleVersion = '1.0'
RequiredModules = 'ShowUI'
RequiredAssemblies = 'System.Xaml','System.Windows.Controls.Ribbon'
ModuleToProcess = 'Ribbon.psm1'
GUID = 'b307ebad-cfb1-4c34-895c-471792c513db'
FunctionsToExport = @('New-KeyTipControl','New-RibbonContextualTabGroupsPanel','New-RibbonGalleryCategoriesPanel','New-RibbonGalleryItemsPanel','New-RibbonGroupItemsPanel','New-RibbonGroupsPanel','New-RibbonMenuItemsPanel','New-RibbonQuickAccessToolBarOverflowPanel','New-RibbonQuickAccessToolBarPanel','New-RibbonTabHeadersPanel','New-RibbonTabsPanel','New-RibbonTitlePanel','New-StarLayoutInfo','New-Ribbon','New-RibbonMenuButton','New-RibbonApplicationMenu','New-RibbonMenuItem','New-RibbonApplicationMenuItem','New-RibbonSplitMenuItem','New-RibbonApplicationSplitMenuItem','New-RibbonButton','New-RibbonCheckBox','New-RibbonComboBox','New-RibbonContextMenu','New-Ri
@Jaykul
Jaykul / Reflection.psm1
Last active March 12, 2018 23:32
Get-ParseResults
function Get-ParseResults {
param(
# The script or file path to parse
[Parameter(Mandatory=$true, ValueFromPipeline=$True, ValueFromPipelineByPropertyName=$True)]
[Alias("Path","PSPath")]
$Script
)
$ParseErrors = $null
$Tokens = $null
@Jaykul
Jaykul / Generator.psm1
Last active March 12, 2018 23:34
Types And Inheritance
Import-Module poke -Force
$xlr8r = [psobject].assembly.gettype("System.Management.Automation.TypeAccelerators")
# ScriptBlock Parsing using a Parser Instance so we can pass it to the DefineTypeHelper later
function New-Type {
param(
[ScriptBlock]$TypeDefinition,
@Jaykul
Jaykul / NancyFx.ps1
Created March 10, 2015 20:59
Playing with classes in PowerShell 5 (February Preview)
# In the real world, I'm trying to use Nancy.NancyModule, but for demo's sake, it can be this simple:
add-type @'
namespace Nancy
{
public abstract class NancyModule
{
protected NancyModule() { }
}
}
'@
@Jaykul
Jaykul / Example.ps1
Last active March 12, 2018 23:45
LocalizeCounterNames
$Processor, $Privileged = Get-CounterLocalizedName "Processor", "% Privileged Time"
Get-Counter "\$Processor(_Total)\$Privileged"
@Jaykul
Jaykul / ChildProcess.psm1
Last active March 12, 2018 23:47
ChildProcess
function Stop-ChildProcess {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(ValueFromPipelineByPropertyName=$true, ParameterSetName="Name")]
[String[]]$Name,
[Parameter(ValueFromPipelineByPropertyName=$true, ParameterSetName="ID")]
[Alias("ProcessID")]
[Int[]]$ID,
@Jaykul
Jaykul / FileOps.ps1
Created July 8, 2015 19:00
Simple File IO with insufficient parameter handling
function Tail-File {
[CmdletBinding()]
param($Path,
[System.Text.Encoding]$Encoding = $([System.Text.Encoding]::UTF8)
)
$File = Convert-Path $Path
try {
$Stream = New-Object System.IO.FileStream $File, "Open", "Read", "ReadWrite", 2048, "None"
@Jaykul
Jaykul / Set-BingWallpaper.ps1
Last active March 12, 2018 23:48
Set the wallpaper(s) without changing options. Sets a different wallpaper on each monitor! :-)
[CmdletBinding()]
param(
# If you want to try the bing images from other countries, fiddle around with this (try en-GB, for instance)
$Culture = 'en-US',
# If you want to (re)use yesterday's wallpapers, fiddle around with this
$Offset = 0
)
Add-Type -Assembly System.Windows.Forms, PresentationFramework
Add-Type -Name Windows -Namespace System -MemberDefinition @'
@Jaykul
Jaykul / Update-ParameterValues.ps1
Created November 21, 2015 06:17
PSBoundParameterValues++
Update-TypeData -TypeName System.Management.Automation.InvocationInfo -MemberName ParameterValues -MemberType ScriptProperty -Value {
$results = @{}
foreach($parameter in $this.MyCommand.Parameters.GetEnumerator()) {
try {
$key = $parameter.Key
if($value = Get-Variable -Name $key -Scope 1 -ValueOnly -ErrorAction Ignore) {
$results.$key = $value
}
} finally {}
}