Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Fennell rfennell

View GitHub Profile
@rfennell
rfennell / Remove-DeletedGitBranches.ps1
Last active Jul 6, 2022
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
param
(
[Parameter()]
[Switch]
$Force
)
Write-Host "Getting list of branches"
$output = [string] (& git.exe branch 2>&1)
$mainbranch = "main"
@rfennell
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
rfennell / AZDO-StageDependencyVariables.yml
Last active Jun 30, 2022
Azure DevOps Pipelines Stage Dependency Variables Usage Demo
View AZDO-StageDependencyVariables.yml
parameters:
- name: Value
type: boolean
default: true
pool:
vmImage: ubuntu-latest
stages:
@rfennell
rfennell / CommitToThisRepo.ps1
Created Jan 19, 2018
PowerShell script add a commit to the current repo for use inside a VSTS CI/CD process
View CommitToThisRepo.ps1
(
$file = "readme.md",
$text = "Automated edit",
$wi = "#13 #14"
)
"Set config"
git config --global user.email "builduser@dummy.local" # any values will do, if missing commit will fail
git config --global user.name "Build user"
@rfennell
rfennell / blog2md.js
Created Jun 25, 2022
A quick edit to the blog2md (https://github.com/palaniraja/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
rfennell / Unregister-Agent.ps1
Created Dec 20, 2019
Finds an Azure Build agent, takes it off line then removes it registration
View Unregister-Agent.ps1
param
(
[parameter(Mandatory = $true, HelpMessage = "Azure DevOps PAT token")]
$pat,
[parameter(Mandatory = $true, HelpMessage = "URL of Azure DevOps instance e.g. https://dev.aure.com/myinstance")]
$url,
[parameter(Mandatory = $true, HelpMessage = "Azure DevOps Agent Pool name")]
$pool ,
[parameter(Mandatory = $true, HelpMessage = "Based name for agent to search for e.g MyAgent as part of B1MyAgent-123")]
$agentBaseName ,
@rfennell
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
pool:
vmImage: windows-latest
variables:
- name: system.debug
value: true
stages:
- stage: Stage1
jobs:
@rfennell
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 Organisation.in the main sample https://docs.github.com/en/issues/trying-out-the-new-projects-experience/automating-projects
View add_issue_to_project
name: Add Issue to project
on:
issues:
types: [opened]
jobs:
track_issue:
runs-on: ubuntu-latest
steps:
- name: Get project data
@rfennell
rfennell / Update-AppConfig.ps1
Created Feb 13, 2018
PowerShell script to update an app.config file based on a parameters.xml
View Update-AppConfig.ps1
function Update-AppConfig
{
[cmdletbinding()]
param
(
[parameter(Mandatory = $true, HelpMessage = "Name of app.exe.config file")]
[string]$AppConfigFile,
[parameter(Mandatory = $false, HelpMessage = "Name of parameters.xml file")]
[string]$ParametersFile = "parameters.xml"
@rfennell
rfennell / Set-Azure DevOpsBrnachPolicies.ps1
Created Nov 12, 2021
Set Azure DevOps All Repositories Branch policies
View Set-Azure DevOpsBrnachPolicies.ps1
param
(
[parameter(Mandatory=$true,HelpMessage="The target Azure DevOps Instance")]
$org,
[parameter(Mandatory=$true,HelpMessage="The new project name")]
$projectName,
[parameter(Mandatory=$true,HelpMessage="A PAT with access to target org")]
$pat