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
@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",
@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 / 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
}
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 / 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")
#!/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"
#use this task to execute inline powershell in your build https://marketplace.visualstudio.com/items?itemName=petergroenewegen.PeterGroenewegen-Xpirit-Vsts-Build-InlinePowershell
#add the script below
#pass the following as arguments: -buildnumber $(Build.BuildNumber) -out $(Build.ArtifactStagingDirectory)\out.txt -guid $(System.TeamProjectId)
#replace the two placeholders with a Personal Access Token and your VS Account name; the part behind https://dev.azure.com/
Param(
[string]$buildnumber,
[string]$out,
[string]$guid
)

Keybase proof

I hereby claim:

  • I am maxmelcher on github.
  • I am maxmelcher (https://keybase.io/maxmelcher) on keybase.
  • I have a public key ASCgacYQpljLL6v7oEAepeDRniywArNynL4EoMHsn3C51Qo

To claim this, I am signing this object:

<#
.TERMS
No terms - use on your own risk!
.SYNOPSIS
This script efficiently emtpties are large list and is approximately 30 times faster than deleting item by item.
You need to have the SharePoint Online SDK (https://www.microsoft.com/en-us/download/details.aspx?id=42038) installed to run this script.
.PARAMETER weburl
SharePoint Online web URL, for example 'https://contoso.sharepoint.com'.
.PARAMETER listname
<#
.TERMS
Refer to Microsoft Connect Terms of use http://connect.microsoft.com/terms.aspx#O
.SYNOPSIS
This script onboards your SharePoint Online (SPO) tenant into the cloud hybrid search SharePoint Server 2013 Preview/SharePoint 2016 Preview
.PARAMETER PortalUrl
SharePoint Online portal URL, for example 'https://contoso.sharepoint.com'.
.PARAMETER HybridSsaId
Name or id (Guid) of the cloud hybrid search application, created with the CreateCloudSSA script.
.PARAMETER Credential