Skip to content

Instantly share code, notes, and snippets.

@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
Check that the 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: 2024.02.15
@dancing-groot
dancing-groot / Write-SimpleLog.ps1
Last active March 25, 2024 11:06
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 Write-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
#>
@dancing-groot
dancing-groot / Write-Event.ps1
Last active July 6, 2023 10:23
A framework for creating an event log, writing to it and optionally writing to the output if that's not possible for some reason
[CmdletBinding()]
param()
# This works for PowerShell 5.1 but needs to be re-written for 7
#region FUNCTIONS
function Initialize-EventLog
{
<#
.SYNOPSIS