Skip to content

Instantly share code, notes, and snippets.

View chamindac's full-sized avatar

chamindac

View GitHub Profile
@chamindac
chamindac / AzureRGVMPowerGo.ps1
Created December 7, 2016 07:02 — forked from darrenjrobinson/AzureRGVMPowerGo.ps1
ParallelRMRGVirtualMachines
param(
[string]$power,
[string]$azureResourceGroup
)
if (!$power){Write-host "No powerstate specified. Use -Power start|stop"}
if (!$azureResourceGroup){Write-host "No Azure Resource Group specified. Use -azureResourceGroup 'ResourceGroupName'"}
# see if we already have a session. If we don't don't re-authN
if (!$AzureRMAccount.Context.Tenant) {
@chamindac
chamindac / FindActiveTeamProjectsWithCodeCheckinsorCommits.ps1
Created July 27, 2018 03:21
Find Active Team Projects in VSTS/TFS based on commits and check-ins
param(
[Parameter(Mandatory=$true)]
[string] $token,
[Parameter(Mandatory=$true)]
[string] $fromDate,
[Parameter(Mandatory=$true)]
[string] $collectionUri
)
@chamindac
chamindac / FindBuildsDefsForGivenRepo.ps1
Last active August 29, 2018 02:41
Find build definitions of any given Tfs Git repos or TFVC version control and list them out in an html file
param(
[Parameter(Mandatory=$true)]
[string] $token,
[Parameter(Mandatory=$true)]
[string] $collectionUri,
[Parameter(Mandatory=$true)]
[string] $teamProjectName,
[string] $repoName = '*'
)
@chamindac
chamindac / GetMostFrequentlyModifiedFiles.ps1
Created October 23, 2018 13:38
Get most frequently modified Azure DevOps git repo files in a Team Project .\GetMostFrequentlyModifiedFiles.ps1 -token 'yourPAT' -fromDate '5/02/2018' -collectionUri 'https://dev.azure.com/yourAccount' -teamProjectName 'yourteamProject' -repoName @('repo1*', '*corereop*') -branchNameFilter @('master*','develop*')
param(
[Parameter(Mandatory=$true)]
[string] $token,
[Parameter(Mandatory=$true)]
[string] $fromDate,
[Parameter(Mandatory=$true)]
[string] $collectionUri,
[Parameter(Mandatory=$true)]
[string] $teamProjectName,
@chamindac
chamindac / UpdateReleasePipelineVariable.ps1
Created April 12, 2019 03:01
Script to update release pipeline variable with Azure DevOps REST API - a modified version of script available here https://blogs.msdn.microsoft.com/aseemb/2016/05/23/how-to-update-release-level-variables-using-rm-rest-apis/
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $VariableName,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $VariableValue
)
## Construct a basic auth head using PAT
@chamindac
chamindac / PRBranchPatternControlinPRvalidationBuildforAzureGitRepos.ps1
Last active March 31, 2020 05:56
This script can be added as a task in pull request validation build with a branching pattern defined as a variable. For more information see http://chamindac.blogspot.com/2019/05/controlling-pull-request-source.html
$sourceBranch = $env:System_PullRequest_SourceBranch
$targetBranch = $env:System_PullRequest_TargetBranch
$branchControlPattern = $(BranchControlPattern)
Write-Host ('PR Source Branch: ' + $sourceBranch)
Write-Host ('PR Target Branch: ' + $targetBranch)
@chamindac
chamindac / CreateAzureWebAppForNetCore3.ps1
Last active March 31, 2020 06:10
This script can be used to create an Azure web app and add the .NET core 3.0 extensions in an Azure DevOps release pipeline. See https://chamindac.blogspot.com/2019/08/creating-azure-web-app-supporting-net.html
param (
[Parameter(Mandatory=$true)]
[string] $azureAppId,
[Parameter(Mandatory=$true)]
[string] $azureAppPwd,
[Parameter(Mandatory=$true)]
[string] $azureTenant,
[Parameter(Mandatory=$true)]
[string] $resourceGroupName,
[Parameter(Mandatory=$true)]
@chamindac
chamindac / BranchPolicyCopy.ps1
Created April 7, 2020 06:02
Copy Branch policies from a Azure DevOps Git branch to another branch
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string] $AzureDevOpsPAT,
[Parameter(Mandatory=$true)]
[string] $OrganizationName,
[Parameter(Mandatory=$true)]
[string] $teamProjectName,
[Parameter(Mandatory=$true)]
@chamindac
chamindac / ExcuteTerraformPlan.ps1
Created October 18, 2020 15:14
Execute Terraform Plan By Building Parameter String
param
(
[Parameter(Mandatory=$true)]
[string] $tfStateFilePath,
[Parameter(Mandatory=$true)]
[string] $planFilePath,
[Parameter(Mandatory=$true)]
[string] $AzureSubscriptionId,
[Parameter(Mandatory=$true)]
[string] $AzureSPNAppId,
@chamindac
chamindac / win10dockerinstallwsl2.ps1
Last active September 22, 2024 08:16
This script automates installation of Docker Desktop on Windows 10 and uses WSL2
set-executionpolicy -scope CurrentUser -executionPolicy Bypass -Force
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator))
{
# Relaunch as an elevated process:
Start-Process powershell.exe "-File",('"{0}"' -f $MyInvocation.MyCommand.Path) -Verb RunAs
exit
}
$ProgressPreference = 'SilentlyContinue'