Skip to content

Instantly share code, notes, and snippets.


Richard Fennell rfennell

View GitHub Profile
rfennell / fixalias.ps1
Created Jul 1, 2022
A script to update a Hugo content file to provide an alias that matches a Wordpress permalink
View fixalias.ps1
$basepath = "C:\tmp\bmBlog\content"
$files = Get-ChildItem -path $basepath -Filter "*.md" -Recurse | % { $_.FullName}
foreach ($file in $files) {
$f = get-item $file
$content = (Get-Content -path $f.FullName)
foreach ($l in $content) {
rfennell / blog2md.js
Created Jun 25, 2022
A quick edit to the blog2md ( tools to place exported posts from a multi site WordPress Server in folders based on the sub site name
View blog2md.js
'use strict';
Usage: blog2md b|w <BLOGGER/WordPress BACKUP XML> <OUTPUT DIR>
const fs = require('fs');
const os = require('os');
rfennell / Azure-DevOps-Variables-Sample-yml
Created May 5, 2022
Example of how to pass variables between Azure DevOps stages
View Azure-DevOps-Variables-Sample-yml
vmImage: windows-latest
- name: system.debug
value: true
- stage: Stage1
rfennell / AZDO-StageDependencyVariables.yml
Last active Jun 30, 2022
Azure DevOps Pipelines Stage Dependency Variables Usage Demo
View AZDO-StageDependencyVariables.yml
- name: Value
type: boolean
default: true
vmImage: ubuntu-latest
rfennell / Set-Azure DevOpsBrnachPolicies.ps1
Created Nov 12, 2021
Set Azure DevOps All Repositories Branch policies
View Set-Azure DevOpsBrnachPolicies.ps1
[parameter(Mandatory=$true,HelpMessage="The target Azure DevOps Instance")]
[parameter(Mandatory=$true,HelpMessage="The new project name")]
[parameter(Mandatory=$true,HelpMessage="A PAT with access to target org")]
rfennell / add_issue_to_project
Created Oct 15, 2021
A GitHub Actions workflow to add any newly created issues to a Project within a GitHub user (pro or free) account as opposed to a GitHub Enterprise the main sample
View add_issue_to_project
name: Add Issue to project
types: [opened]
runs-on: ubuntu-latest
- name: Get project data
rfennell / Move-GitTag.ps1
Created Jul 8, 2021
Move a Git tag to the most recent commit
View Move-GitTag.ps1
$trunk = 'main'
& git push origin :refs/tags/$tagname
& git tag -fa $tagname -m "Current $tagname release"
& git push origin $trunk --tags
rfennell / Get-AzureDevOpsEnvApprovel.ps1
Last active May 22, 2021
A code fragment that can be used in an Azure DevOps PowerShell task to find the approver of the current stage of a multi stage YAML pipeline
View Get-AzureDevOpsEnvApprovel.ps1
try {
# this block is in its own try/catch as it uses undocumented API calls, so will fail safe
# we need to stage ID which is only available via a REST call
$uri = "$(System.CollectionUri)/$(System.TeamProject)/_apis/build/builds/$(Build.BuildID)/timeline?api-version=6.0"
$response = Get-WebClient.DownloadString($uri) | ConvertFrom-Json
$stage = $response.records | where-object -property name -eq "$(System.StageName)"
# now we can get the approval, we have to use a new webclient instance else you get a 400 Bad Request error
$uri = "$(System.CollectionUri)_apis/Contribution/HierarchyQuery/project/$(System.TeamProject)?api-version=6.1-preview.1"
$payload = "{`"contributionIds`":[`"ms.vss-build-web.checks-panel-data-provider`"],`"dataProviderContext`":{`"properties`":{`"buildId`":`"$(Build.BuildID)`",`"stageIds`":`"$($`",`"checkListItemType`":1,`"sourcePage`":{`"url`":`"$(System.CollectionUri)/$(System.TeamProject)/_build/results?buildId=$(Build.BuildID)&view=results`",`"routeId`":`"ms.vss-bui
rfennell / Remove-DeletedGitBranches.ps1
Last active Mar 16, 2021
A PowerShell script to do a git fetch with a prune then also delete any local branches of the same name
View Remove-DeletedGitBranches.ps1
Write-Host "Getting list of branches"
$output = [string] (& git.exe branch 2>&1)
$mainbranch = "main"
rfennell / BuildAgent.ps1
Last active Jan 20, 2021
A Lability definition to create an Azure DevOps Agent
View BuildAgent.ps1
configuration BuildAgent {
param (
[Int]$RetryCount = 100,
[Int]$RetryIntervalSec = 30