Skip to content

Instantly share code, notes, and snippets.

View steviecoaster's full-sized avatar
🤠
It's a sweet day to write some Powershell

Stephen Valdinger steviecoaster

🤠
It's a sweet day to write some Powershell
View GitHub Profile
@steviecoaster
steviecoaster / InternalizePackageIcons.ps1
Last active December 17, 2020 19:34
Internalize package icons for packages created with Chocolatey's Package Internalizer
<#
.SYNOPSIS
Internalize package icons for internalized packages
.EXAMPLE
$params = @{
InternalizerDownloadPath = 'C:\internalized\download\'
IconRepository = 'http://nexus.fabrikam.com:8081/repository/icons/'
PackageRepository = 'http://nexus.fabrikam.com:8081/repository/choco/'
}
@steviecoaster
steviecoaster / ChocoAnsible.ps1
Last active December 3, 2020 02:23
Get started with ansible using chocolatey
if(-not (Get-Command choco)){
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
choco install wsl wsl-ubuntu-2004 vscode vscode-powershell vscode-ansible -y
@steviecoaster
steviecoaster / Install-ChocolateyNotifyPackage.ps1
Last active November 19, 2020 21:41
Mobile push notifications when installing Chocolatey packages
Function Install-ChocolateyNotifyingPackage {
[cmdletBinding()]
param(
[parameter()]
[string]
$Package
)
process {
Function New-ChocolateyExtension {
<#
.SYNOPSIS
Generate chocolatey extension package from existing powershell module
.DESCRIPTION
Generate Chocolatey extension package from existing powershell module
.PARAMETER PowerShellModule
Use this to generate an extension from an existing, installed PowerShell module
$outdated = choco outdated -r | ConvertFrom-Csv -Delimiter '|' -Header 'PackageName', 'CurrentVersion', 'LatestVersion', 'Pinned'
$outdated = $outdated | Select-Object PackageName, CurrentVersion, LatestVersion, @{Name = 'Outdated'; Expression = { if ([version]$_.LatestVersion -gt [version]$_.CurrentVersion) { $true } else { $false } } }
$outdatedpackages = $outdated | Where-Object { $_.Outdated -eq $true } | Select-Object -First 4
$packageCollection = @()
$x = 24020
foreach ($odp in $outdatedpackages) {
@steviecoaster
steviecoaster / Remove-RemoteGitBranch.ps1
Created October 21, 2020 19:26
Quick PowerShell function to delete remote git branches
function Remove-RemoteGitBranch {
[cmdletbinding()]
param(
[Parameter(Mandatory = $true, Position = 0)]
[String]
$Branch
)
process {
@steviecoaster
steviecoaster / New-PackageConfig.ps1
Last active July 22, 2021 02:45
Backup Chocolatey Packages To File
<#
.SYNOPSIS
Creates a packages.config file from installed choco packages
.PARAMETER SourceFriendlyName
The friendly name of an available choco source on the system. This will explicity set the source in the config file
such that installation on the new system will come from this source.
.PARAMETER OutputFile
The config file to save output too. Must end in '.config'.
@steviecoaster
steviecoaster / InstallAndConfigureJenkins.ps1
Last active March 20, 2020 03:48
Configuring Jenkins using Selenium.....because I'm a f*@#%# idiot like that
choco install googlechrome -y --no-progress
choco install jenkins -y -s https://chocolatey.org/api/v2
choco install selenium-chrome-driver -y -s https://chocolatey.org/api/v2
$ModuleBase = (Get-Module -ListAvailable Selenium).ModuleBase
Unblock-File -Path 'C:\tools\selenium\*'
Get-Process -Name *chrome*, *firefox*, *gecko* | Stop-Process -Force
Get-ChildItem -Path 'C:\tools\selenium\*' | Copy-Item -Destination "$ModuleBase\assemblies\" -Force -ErrorAction SilentlyContinue
Import-Module Selenium
@steviecoaster
steviecoaster / OpenFileDialog.ps1
Last active November 4, 2021 04:44
Powershell Open File Dialog
#Thomas Rayner is awesome. Everyone should be like Thomas. Mostly ganked from here: https://thomasrayner.ca/open-file-dialog-box-in-powershell/
function Open-FileDialog {
[cmdletBinding()]
param(
[Parameter()]
[ValidateScript({Test-Path $_})]
[String]
$InitialDirectory
)
Add-Type -AssemblyName System.Windows.Forms
@steviecoaster
steviecoaster / HappyBirthdayMike.ps1
Created February 7, 2020 22:21
Happy Birthday, Mike Kanakos!!
function Resolve-Note {
[OutputType([void])]
[CmdletBinding(SupportsShouldProcess, ConfirmImpact = 'Low')]
param(
[Parameter(Position = 0, Mandatory, ValueFromPipeline,ValueFromPipelineByPropertyName)]
[Alias('♪', '♫')]
[ValidateSet('C', 'C#', 'Db', 'D', 'D#', 'Eb', 'E', 'F', 'F#', 'Gb', 'G', 'G#', 'Ab', 'A', 'A#', 'Bb', 'B', 'R')]
[string]
$Note,