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 / 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,
@steviecoaster
steviecoaster / Start-Streaming.ps1
Last active October 8, 2019 23:17
Get Started W/ @powershelllive streaming!
#ensure chocolatey is Installed
If(-not (Test-Path $env:ChocolateyInstall)){
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process
iex (New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/Install.ps1')
}
refreshenv
@steviecoaster
steviecoaster / ConvertFrom-StringData Changes.md
Created October 3, 2019 00:20
ConvertFrom-StringData Changes

Example 9: Use a different delimiter to split a string into a hashtable

$Here = @'
Msg1 : The string parameter is required.
Msg2 : Credentials are required for this command.
Msg3 : The specified variable does not exist.
'@
ConvertFrom-StringData -StringData $Here -Delimiter ':'
@steviecoaster
steviecoaster / Get-DadJokeSound.ps1
Created August 30, 2019 02:04
Get-DadJokes.....WITH SOUND!!!!
function Get-DadJoke {
[cmdletBinding()]
Param()
process {
$header = @{
Accept = "application/json"
}
$joke = Invoke-RestMethod -Uri "https://icanhazdadjoke.com/" -Method Get -Headers $header
@steviecoaster
steviecoaster / Get-DadJoke.ps1
Created August 19, 2019 21:14
Because dad jokes are always fun.
function Get-DadJoke {
[cmdletBinding()]
Param()
process {
$header = @{
Accept = "application/json"
}
$joke = Invoke-RestMethod -Uri "https://icanhazdadjoke.com/" -Method Get -Headers $header
$joke.joke
@steviecoaster
steviecoaster / Remove-ChocoLog.ps1
Created July 23, 2019 23:47
Remove a chocolatey log that has grown unruly in size
function Remove-ChocoLog {
<#
.SYNOPSIS
Remove a chocolatey log from a system
.DESCRIPTION
Based on size threshold, will remove a chocolatey.log file from the specified system(s).
.PARAMETER LogThresholdMB
Size in MB to determine whether or not to prune a log
@steviecoaster
steviecoaster / Get-ChocoLogSize.ps1
Created July 23, 2019 23:30
Query size of a chocolatey log
function Get-ChocoLogSize {
<#
.SYNOPSIS
Returns the size of the chocolatey.log file in MB
.PARAMETER Computername
The system to query. Defaults to the local COMPUTERNAME
.EXAMPLE
Get-ChocoLogSize