Skip to content

Instantly share code, notes, and snippets.

Marcus Felling MarcusFelling

Block or report user

Report or block MarcusFelling

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View run.ps1
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Write to the Azure Functions log stream.
"PowerShell HTTP trigger function processed a request."
# Get Personal Access Token (PAT) from query parameter of the request.
$PAT = $Request.Query.PAT
View Update-ReleaseDefinitionsWindowsMachineFileCopyTask.ps1
<#
.Description
Script used to bulk update Azure Pipeline release definition's WindowsMachineFileCopy from v1 to v2
.Example
.\Update-ReleaseDefinitionsWindowsMachineFileCopyTask.ps1 -PAT "NoTaReAlPaT" -AzureDevOpsProjectURL "https://vsrm.dev.azure.com/{organization}/{project}"
#>
[CmdletBinding()]
Param
@MarcusFelling
MarcusFelling / example.yml
Created Jan 23, 2019
Audhari Poornimarao YAML example
View example.yml
# Build app using Azure Pipelines
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript?view=vsts
pool:
vmImage: 'vs2017-win2016'
steps:
– script: echo hello world
– task: NodeTool@0
inputs:
versionSpec: '8.x'
View Get-ReleasesNotInProduction.ps1
<#
.Description
Script used to gather all releases that have been successfully deployed to QA,
but not yet promoted to Prod environments. Outputs release definition name and URL of release to LatestReleases.html
.Example
.\Get-ReleasesNotInProduction.ps1 -PAT "NoTaReAlPaT" -AzureDevOpsProjectURL "https://vsrm.dev.azure.com/{organization}/{project}"
#>
[CmdletBinding()]
View KillDotnetProcesses.ps1
$dotnet = Get-Process dotnet -ErrorAction SilentlyContinue
If($dotnet){
taskkill.exe /F /IM dotnet.exe
}
Else{
"No dotnet.exe tasks to kill"
}
View CreateRelease.ps1
<#
.DESCRIPTION
Creates a new release for the specified release definition name, using the latest artifact versions available
.Parameter PAT
Personal Access token. It's recommended to use a service account and pass via encrypted build definition variable.
https://docs.microsoft.com/en-us/vsts/organizations/accounts/use-personal-access-tokens-to-authenticate?view=vsts
.Parameter ReleaseDefinitionName
Name of release definition to create a release for
.Notes
-Parameters are outside of functions in order to be passed by TFS build definition variables
View AssemblyInfoVersioning
$VersionRegex = "\d+\.\d+\.\d+\.\d+"
$Files = Get-ChildItem $Env:BUILD_SOURCESDIRECTORY -recurse -include "*Properties*" |
?{ $_.PSIsContainer } |
ForEach { Get-ChildItem -Path $_.FullName -Recurse -include AssemblyInfo.* }
If($Files){
"Will apply $env:Version to $($Files.count) files."
ForEach ($File in $Files) {
$Filecontent = Get-Content($File)
attrib $File -r
$Filecontent -replace $VersionRegex, $env:Version | Out-File $File
@MarcusFelling
MarcusFelling / VSTSAgentInstall.rb
Last active Dec 26, 2017
Chef recipe to install VSTS agents
View VSTSAgentInstall.rb
# Array of agents to create
example_agents = ['Example-1', "Example-2", "Example-3", "Example-4", "Example-5", "Example-6"]
example_agentpool = ''
install_dir = 'H:\\agents\\'
sv_user = '' # Windows log on account for agent service
sv_password = ''
vsts_url = 'https://youraccount.visualstudio.com'
vsts_token = '' # Temporary PAT to use when installing the agents
# Download install files from S3
View ExitStandby.ps1
# Part 2 of 2
# Part 1 Places EC2 instance into autoscaling group's standby mode.
# Part 2 Exits standby mode and waits for instance to be InService.
param (
[Parameter(Mandatory=$true)][string]$ASGEnterStandbyDeployStep, # Deploy step name of EnterStandby.ps1
[Parameter(Mandatory=$true)][string]$ASGNameVariable, # Variable name that is set by EnterStandby.ps1 for ASG Name
[Parameter(Mandatory=$true)][string]$registrationCheckInterval,
[Parameter(Mandatory=$true)][string]$maxRegistrationCheckCount
)
View EnterStandby.ps1
# Part 1 of 2
# Part 1 Places EC2 instance into autoscaling group's standby mode.
# Part 2 Exits standby mode and waits for instance to be InService.
param (
[Parameter(Mandatory=$true)][string]$ASGNameVariable # Passed in Octopus script step
)
# Get EC2 Instance
Try
{
$response = Invoke-RestMethod -Uri "http://169.254.169.254/latest/meta-data/instance-id" -Method Get
You can’t perform that action at this time.