Skip to content

Instantly share code, notes, and snippets.

@rfennell
rfennell / Copy-GitLabRepoToAzureDevOps.ps1
Last active April 23, 2024 12:35
Copy repos from GitLab to Azure DevOps
<#
.SYNOPSIS
Copies GitLab repositories to Azure DevOps.
.DESCRIPTION
This script retrieves GitLab repositories using the provided GitLab token and copies them to an Azure DevOps project.
.PARAMETER gitlabtoken
Specifies the GitLab token to authenticate with the GitLab API.
Create a personal access token in GitLab by navigating to Profile > Edit Profile > Access Tokens.
@rfennell
rfennell / revert-workitems.ps1
Last active April 17, 2024 14:45
A PowerShell script to revert the values in a specified list of fields for a list of work items returned by a WIQL query
[CmdletBinding()]
<#
.SYNOPSIS
Reverts work items to their previous state in Azure DevOps based on the specified criteria.
.DESCRIPTION
Reverts work items to their previous state in Azure DevOps based on the specified criteria.
@rfennell
rfennell / Copy-LastBlogCommit.ps1
Created March 22, 2024 09:01
When run in a Hugo based Static website Git Repo will copy content to another repo
param (
[string]$blog = "rfennell",
[string]$destination = "C:\projects\bm-source\BMBlogs-Hugo"
)
write-host "Copying last blog commit"
$commandOutput = Invoke-Expression "git diff-tree --no-commit-id --name-only -r HEAD"
foreach ($sourceFile in $commandOutput) {
@rfennell
rfennell / CommitToThisRepo.ps1
Created January 19, 2018 19:36
PowerShell script add a commit to the current repo for use inside a VSTS CI/CD process
(
$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 / AZDO-StageDependencyVariables.yml
Last active January 29, 2024 18:59
Azure DevOps Pipelines Stage Dependency Variables Usage Demo
parameters:
- name: Value
type: boolean
default: true
pool:
vmImage: ubuntu-latest
stages:
@rfennell
rfennell / DockerCompose.yml
Last active November 23, 2023 09:10
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
@rfennell
rfennell / Remove-DeletedGitBranches.ps1
Last active July 29, 2023 10:08
A PowerShell script to do a git fetch with a prune then also delete any local branches of the same name
# To set as Git Alias
# git config --global alias.tidy "!pwsh -command C:\MyFolder\Remove-DeletedGitBranches.ps1"
param
(
[Parameter()]
[Switch]
$Force
)
Write-Host "Getting list of branches"
@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 / 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"
)