Skip to content

Instantly share code, notes, and snippets.

@rfennell
rfennell / Azure-DevOps-Variables-Sample-yml
Created May 5, 2022 08:47
Example of how to pass variables between Azure DevOps stages
pool:
vmImage: windows-latest
variables:
- name: system.debug
value: true
stages:
- stage: Stage1
jobs:
@rfennell
rfennell / blog2md.js
Created June 25, 2022 10:58
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
'use strict';
/***
Usage: blog2md b|w <BLOGGER/WordPress BACKUP XML> <OUTPUT DIR>
*/
const fs = require('fs');
const os = require('os');
@rfennell
rfennell / fixalias.ps1
Created July 1, 2022 10:17
A script to update a Hugo content file to provide an alias that matches a Wordpress permalink
$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 / Get-AgentPoolForNamedAgent.ps1
Created September 6, 2022 09:20
A sample script that shows how to find the Azure DevOps agent pool for a named agent. Also shows the call required to delete the agent
function Get-AgentPoolForNamedAgent {
param
(
$pat,
$url,
$agentName
)
$patToken = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($pat)"))
@rfennell
rfennell / DependancyCheckToSonarCloudConvertor.ps1
Last active September 30, 2022 11:46
Script to convert OWASP Dependency Check Results to a format that can be ingested into SonarCloud
param
(
# The OWASP results XML file
$input = "dependancy-results.xml",
# The SonarCloud generic issue JSON file
$output = "dependancy-results.json",
# The file to associate issues with
$filename = "c:\folder\file.cs"
)
@rfennell
rfennell / KeyVaultFilter.yaml
Created February 7, 2023 18:54
An inline task to convert a regex based filter to a comma separated list as required to download Secrets from KeyVault in Azure DevOps
variables:
# the variable used to filter the KeyVault secret list
# This can be a simple prefix and wildcard e.g. 'Config-*''
# Or a more complex regex expression e.g. ^(?:Config-*|Settings-*)
- name: KV-Filter
value: '^(?:Config-*|Settings-*)'
# the variable used to KeyVault name
- name: KV-Name
value: 'bm-kv1'
@rfennell
rfennell / Get-NugetPackage.ps1
Last active April 1, 2023 15:39
Downloading NuGet packages with 'System.Net.WebClient' from an Azure DevOps Artifact feed
param(
$package,
$version,
$azdoOrg,
$feedname,
# provide a, Azure DevOps PAT if it a private feed
$pat,
$DestinationPath = "$package-$version.zip"
)
@rfennell
rfennell / run.csx
Created July 14, 2023 12:24
Azure Function code to send a Tweet to the V2 Twitter API using OAUTH1.0
#r "Newtonsoft.Json"
using System.Text;
using System.Net;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
using OAuth;
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
@rfennell
rfennell / DockerCompose.yml
Last active June 6, 2024 15:55
A BICEP file to deploy Snipe IT to Azure - see the comments below for usage details
version: "3"
services:
snipe-it:
image: snipe/snipe-it:latest
volumes:
- snipeit:/var/lib/snipeit
- snipeit-logs:/var/www/html/storage/logs
volumes:
@rfennell
rfennell / export-tfs-upgate-log-to-csv.ps1
Last active October 5, 2023 10:44
Extracts the timestamps from a TFS/Azure DevOps upgrade log or ease of charting
param
(
$logfile = "TPC\_ApplyPatch.log",
$outfile = "out.csv"
)
# A function to covert the start and end times to a number of minutes
# Can't use simple timespan as we only have the time portion not the whole datetime
# Hence the hacky added a day-1 second