Skip to content

Instantly share code, notes, and snippets.

View MaxMelcher's full-sized avatar
🏠
Working from home

Max Melcher MaxMelcher

🏠
Working from home
View GitHub Profile
#!/bin/sh
echo $@
echo "start"
cd /home/azuredevopsuser
mkdir agent
cd agent
AGENTRELEASE="$(curl -s https://api.github.com/repos/Microsoft/azure-pipelines-agent/releases/latest | grep -oP '"tag_name": "v\K(.*)(?=")')"
AGENTURL="https://vstsagentpackage.azureedge.net/agent/${AGENTRELEASE}/vsts-agent-linux-x64-${AGENTRELEASE}.tar.gz"
@MaxMelcher
MaxMelcher / devops_win.ps1
Last active February 20, 2024 07:02
Powershell to install the latest Azure DevOps Agent
param (
[string]$URL,
[string]$PAT,
[string]$POOL,
[string]$AGENT
)
Write-Host "start"
if (test-path "c:\agent")
function Prompt {
try {
$history = Get-History -ErrorAction Ignore -Count 1
if ($history) {
Write-Host "[" -NoNewline
$ts = New-TimeSpan $history.StartExecutionTime $history.EndExecutionTime
switch ($ts) {
{$_.TotalSeconds -lt 1} {
[int]$d = $_.TotalMilliseconds
@MaxMelcher
MaxMelcher / scan.ps1
Created November 7, 2019 09:35
on demand policy scan
$subscriptionID = “<your-subscription-ID-goes-here>"
# Get AAD Access Token
$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Authorization'='Bearer ' + $token.AccessToken
}
@MaxMelcher
MaxMelcher / get-all-vms.ps1
Created March 27, 2020 14:50
VMs, Databases, Storage
<#
.SYNOPSIS
List all Azure VMs across all subscriptions
.DESCRIPTION
List all Azure VMs across all subscriptions
.NOTES
File Name : get-all-vms.ps1
Author : Max Melcher ([email protected])
Prerequisite : PowerShell with Azure module
License : Copyright 2020 Max Melcher
@MaxMelcher
MaxMelcher / gist:df618d4b4cc2a2612965f6515bad5e2d
Created June 4, 2021 11:13
Azure Subnet update Private Endpoint Policy
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
},
"variables": {
},
"resources": [
{
"type": "Microsoft.Network/virtualNetworks/subnets",