Skip to content

Instantly share code, notes, and snippets.

😱
So many OSS projects, so little time!

Daniel Scott-Raynsford PlagueHO

😱
So many OSS projects, so little time!
Block or report user

Report or block PlagueHO

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@PlagueHO
PlagueHO / Restore-GitTagForDsc.ps1
Created Jan 6, 2020
Restores the Git Tags for DSC Community Resource modules that were backed up when running Convert-GetTagForDsc
View Restore-GitTagForDsc.ps1
<#
.SYNOPSIS
Restore a set of backed up Git tags from the backup file
created by Convert-GitTagForDsc.ps1 in the $ENV:Temp folder.
.PARAMETER BackupFile
The full path to the backup file created by Convert-GitTagForDsc.ps1.
.PARAMETER Remote
The name of the Git remote repository for your fork.
@PlagueHO
PlagueHO / Convert-GitTagForDsc.ps1
Last active Jan 6, 2020
Converts the Git Tags for DSC Community Resource modules to be compatible with updated CI process
View Convert-GitTagForDsc.ps1
<#
.SYNOPSIS
Convert Git tags to the format required by the DSC Resource module
CI Process.
.PARAMETER Remote
The name of the Git remote repository for your fork.
.PARAMETER Upstream
The name of the Git remote repository for the upstream fork.
@PlagueHO
PlagueHO / Get-AzMetadataServiceScheduledMaintenance.ps1
Created Oct 22, 2019
Get All Scheduled Maintenance Events for an Azure VM using the Azure Metadata Service
View Get-AzMetadataServiceScheduledMaintenance.ps1
Invoke-RestMethod `
-Method GET `
-Uri 'http://169.254.169.254/metadata/scheduledevents?api-version=2017-11-01' `
-UseBasicParsing `
-Headers @{ 'Metadata' = 'true' }
@PlagueHO
PlagueHO / SelectAzureSubscriptionUsingAzCli.sh
Created Oct 10, 2019
Select a specific Azure subscription using Az CLI when more one subscription exists with the same account name
View SelectAzureSubscriptionUsingAzCli.sh
az account set --subscription (az account list --query "[?name=='Visual Studio Enterprise'].{Id:id}" -o tsv)
@PlagueHO
PlagueHO / Convert-ColourNameToColourValueEnumeratorTypeWithDefault.ps1
Created Oct 4, 2019
PowerShell example using an enumerator type to map colour name to value with a default value set for invalid values
View Convert-ColourNameToColourValueEnumeratorTypeWithDefault.ps1
$colourName = 'grey'
# Only needs to be declared once
enum colour {
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
white = 0xFFFFFF
}
@PlagueHO
PlagueHO / Convert-ColourNameToColourValueEnumeratorType.ps1
Last active Oct 4, 2019
PowerShell example using an enumerator type to map colour name to value
View Convert-ColourNameToColourValueEnumeratorType.ps1
$colourName = 'green'
# Only needs to be declared once
enum colour {
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
white = 0xFFFFFF
}
@PlagueHO
PlagueHO / Invoke-FileActionWithSwitch.ps1
Created Sep 1, 2019
Invoke an action on a file using a swtich statement of actions
View Invoke-FileActionWithSwitch.ps1
$VerbosePreference = 'Continue'
$action = 'New'
$path = 'c:\somefile.txt'
$result = switch ($action) {
'New' {
Write-Verbose -Message 'Execute New-Item'
New-Item -Path $path
break
}
@PlagueHO
PlagueHO / Invoke-FileActionWithHashTableAndNullCoalescing.ps1
Created Aug 31, 2019
Invoke an action on a file using a hash table of actions and null coalescing to report invalid action
View Invoke-FileActionWithHashTableAndNullCoalescing.ps1
$VerbosePreference = 'Continue'
$action = 'New'
$path = 'c:\somefile.txt'
$actions = @{
'New' = {
Write-Verbose -Message 'Execute New-Item'
New-Item -Path $path
}
@PlagueHO
PlagueHO / Mapping.psd1
Created Aug 30, 2019
PowerShell example using a hash table in a PSD1 and null coalescing to map colour name to value (mapping data file)
View Mapping.psd1
@{
red = 0xFF0000
green = 0x00FF00
blue = 0x0000FF
white = 0xFFFFFF
}
@PlagueHO
PlagueHO / Convert-ColourNameToColourValueWithHashTableInPsd1AndNullCoalescing.ps1
Created Aug 30, 2019
PowerShell example using a hash table in a PSD1 and null coalescing to map colour name to value
View Convert-ColourNameToColourValueWithHashTableInPsd1AndNullCoalescing.ps1
$colourName = 'green'
$colourMap = Import-LocalizedData -FileName mapping.psd1
$colourValue = ($colourMap[$colourName], 0x0, 1 -ne $null)[0] # Null Coalescing
return $colourValue
You can’t perform that action at this time.