Skip to content

Instantly share code, notes, and snippets.

@dancing-groot
dancing-groot / Convert-FileToBase64.ps1
Last active November 29, 2024 20:11
Convert-FileToBase64
<#
.SYNOPSIS
Convert a file to a Base64 string
.DESCRIPTION
This is typically used for storing images (PNG/JPG) within a script
Code needs to be updated to cater for BMP and ICO
.LINK
https://gist.github.com/dancing-groot/44654c55b767ab8eed6e3edf1a005d30
.NOTES
Version: 2024.11.29
@dancing-groot
dancing-groot / Deploy-Application-Extract.ps1
Created May 31, 2024 09:59
Cloudpaging Player - PSADT extract
If ($deploymentType -ine 'Uninstall')
{
##*===============================================
##* PRE-INSTALLATION
##*===============================================
[String]$installPhase = 'Pre-Installation'
## <Perform Pre-Installation tasks here>
If (Test-Path -LiteralPath "C:\Program Files\Numecent\Application Jukebox Player\JukeboxPlayer.exe")
{
@dancing-groot
dancing-groot / Install-AppWithEvergreen.ps1
Created August 21, 2023 17:40
Install an application with Evergreen
#region FUNCTIONS
function Install-AppWithEvergreen
{
param
(
[string]$EvergreenAppName,
[scriptblock]$EvergreenArgs,
[string]$AppInstallerArgs
)
<#
.SYNOPSIS
Test whether a Windows OS version is supported
.DESCRIPTION
Build a list based on the Windows OS, Edition and Build Number with a pre-defined 'end of life' date
to assess if the OS on this machine is still supported
.LINK
https://gist.github.com/dancing-groot/af52d6e2fea46704f67ffa324c58d2c2
.NOTES
Version: 2025.04.17
@dancing-groot
dancing-groot / Write-SimpleLog.ps1
Last active May 6, 2025 17:21
Function for writing to a log file in plain format, with the option to write the information to the host as well
[CmdletBinding()]
param()
#region FUNCTIONS
function New-SimpleLog
{
<#
.SYNOPSIS
Write information to a log file and optionally to the console
.LINK
@dancing-groot
dancing-groot / Write-Timestamp.ps1
Last active August 1, 2023 16:18
Provide visual feedback when running a script interactively
function Write-Timestamp
{
<#
.SYNOPSIS
Provide visual feedback when running a script interactively
.LINK
https://gist.github.com/dancing-groot/1d606c697959b0c80782d10811dbaec5
.NOTES
Version: 2022.03.10
Author: @dancing-groot
@dancing-groot
dancing-groot / Write-Log.ps1
Last active April 28, 2023 17:31
Function for writing to a log file, either in plain or CMTrace format, with the option to write the information to the host as well (for debugging purposes). Based on https://www.wolffhaven45.com/powershell/write-cmtracelog-dropping-logs-like-a-boss/ and https://janikvonrotz.ch/2017/10/26/powershell-logging-in-cmtrace-format/
[CmdletBinding()]
param()
#region FUNCTIONS
function Write-Log
{
<#
.SYNOPSIS
Write information to a log file, optionally in CMTrace format
.LINK
@dancing-groot
dancing-groot / Write-ProgressHelper.ps1
Last active December 9, 2022 16:17
Generic function for using progress bars - based on https://adamtheautomator.com/write-progress/
#region FUNCTIONS
function Write-ProgressHelper
{
<#
.SYNOPSIS
Generic function for using progress bars
.LINK
https://gist.github.com/dancing-groot/b6b381c48e98409b70cb84c810893b2e
.NOTES
Version: 2022.12.09
@dancing-groot
dancing-groot / Invoke-ElevatedRights.ps1
Last active May 17, 2023 16:59
Add this if your script (or a portion of) needs to run with administrative privileges
function Invoke-ElevatedRights
{
[CmdletBinding()]
param()
<#
.SYNOPSIS
Relaunch the script with elevated rights if required
.DESCRIPTION
Checks if the current user is running the script 'As Administrator'
If they are not, relaunch the script in a new process with elevated rights
<#
.SYNOPSIS
A brief description of the function or script
.DESCRIPTION
A longer description
.NOTES
Version: yyyy.mm.dd
Author: Author Name
Info: Release Notes
#>