Skip to content

Instantly share code, notes, and snippets.

@rfennell
rfennell / Update-LabilityRegistration.ps1
Created December 20, 2019 17:22
Registers a VHD disk image with Lability
param (
[parameter(Mandatory = $true, HelpMessage = "Name of the Lablity enviroment definition")]
$mediaid ,
[parameter(Mandatory = $true, HelpMessage = "UNC path the VHDs are stored on")]
$downloadPath
)
$metadataFiles = Get-ChildItem -Path $downloadPath -filter *.metadata
foreach ($file in $metadataFiles) {
@rfennell
rfennell / Create-LabilityEnvironment.ps1
Last active January 6, 2020 14:17
Creates a new Lability Environment for an Azure DevOps build agent
param
(
[parameter(Mandatory = $true, HelpMessage = "Admin user name for new VM")]
$AgentUser,
[parameter(Mandatory = $true, HelpMessage = "Admin passworduser name for new VM")]
$AgentPassword,
[parameter(Mandatory = $true, HelpMessage = "Azure DevOps PAT token")]
$pat,
[parameter(Mandatory = $true, HelpMessage = "URL of Azure DevOps instance t register agent on e.g. https://dev.aure.com/myinstance")]
@rfennell
rfennell / Remove-LabilityEnviroment.ps1
Last active January 6, 2020 14:16
Calculates the parameters and then removes a Lability environment
param
(
[parameter(Mandatory = $true, HelpMessage = "Lability environment name")]
$environmentName ,
[parameter(Mandatory = $true, HelpMessage = "An idenfication leter)]
$prefix,
[parameter(Mandatory = $true, HelpMessage = "Used as an index for the prefix and to calculate the IP address ")]
$index,
)
@rfennell
rfennell / Unregister-Agent.ps1
Created December 20, 2019 17:09
Finds an Azure Build agent, takes it off line then removes it registration
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 / Copy-UserCapablityToAgent.ps1
Created December 20, 2019 17:03
Poll for an Azure Build Agent to become available and when available copy the capabilities
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 / Add-UserCapablitiesToAgent.ps1
Last active December 20, 2019 17:03
Poll for an Azure Build Agent to become available and when available then add capabilities
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 / Add-CapabilityToAgent.ps1
Last active January 29, 2021 09:27
A bit of PowerShell to add capabilities to a Azure DevOps Pipeline Agent programmatically
##-----------------------------------------------------------------------
## <copyright file="Add-CapabilityToAgent.ps1">(c) Tichard Fennell </copyright>
##-----------------------------------------------------------------------
# Adds capacility tags a Azure DevOps Pipeline agent
# Run in the agent folder
Param
(
[parameter(Mandatory=$true,HelpMessage="Personal Access Token with rights to manage agents")]
$patToken,
param
(
[Parameter(Mandatory = $true)]
[string]$pat,
[Parameter(Mandatory = $true)]
[string]$instance,
[Parameter(Mandatory = $true)]
@rfennell
rfennell / Update-AppConfig.ps1
Created February 13, 2018 09:08
PowerShell script to update an app.config file based on a parameters.xml
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 / 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"