Skip to content

Instantly share code, notes, and snippets.

Brian Moore bmoore-msft

  • Microsoft
  • Fargo, ND
Block or report user

Report or block bmoore-msft

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
@bmoore-msft
bmoore-msft / Get-DeploymentCount.ps1
Created May 3, 2019
Get the count of deployments in each resource group in each subscription
View Get-DeploymentCount.ps1
# use this script to get all the deployments in all subscriptions the current user context has access to - it can
# be useful to find groups that are close to the 800 limit
param(
[int]$deploymentCountWarningLevel = 700 # number of deployments where a warning should be written
)
Disable-AzContextAutosave -Verbose
$subs = Get-AzSubscription
@bmoore-msft
bmoore-msft / remove-deployments.ps1
Created Feb 6, 2019
Delete Deployments from a ResourceGroup Based on a Max Number
View remove-deployments.ps1
#
#this script will delete deployments from a resourceGroup if the number of deployments exceeds the number specified by the Max parameter
#
Param(
[string] [Parameter(Mandatory=$true)] $ResourceGroupName,
[int] [Parameter(Mandatory=$true)] $Max
)
$deployments = Get-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName
@bmoore-msft
bmoore-msft / copy-md-blob.ps1
Created Aug 27, 2018
Copies the blob from a managed disk export to another storage account and creates a sasToken for marketplace publishing
View copy-md-blob.ps1
param
(
[string]$sourceBlobUri,
[String]$StorageAccountName,
[string]$StorageAccountResourceGroupLocation,
[String]$StorageContainerName = 'vhds',
[String]$BlobName = 'marketplace.vhd'
)
#get Dest Storage context
@bmoore-msft
bmoore-msft / Verify-DeploymentGuid.ps1
Last active Jan 16, 2019
Fetch the resources tagged in a pid-[GUID] deployment
View Verify-DeploymentGuid.ps1
<#
Use this script to retrieve the resources that were deployed with a pid-[GUID] tag
Select-AzureRMContext before running the script - it must be run within the subscription context of the deployment
The GUID and resourceGroup name of the deployment are required params
#>
Param(
[GUID][Parameter(Mandatory=$true)]$guid,
[string][Parameter(Mandatory=$true)]$resourceGroupName
)
@bmoore-msft
bmoore-msft / New-CertificateInKeyVault
Created May 25, 2018
Create a new cert, base64 encode it and put it in KeyVault
View New-CertificateInKeyVault
#Requires -Module AzureRM.KeyVault
# Use this script to create a certificate that you can use to secure a Service Fabric Cluster or other VM/SSL scenario
# This script requires an existing KeyVault that is EnabledFor[Template]Deployment (property depends on the scenario)
# To create a new vault and set the EnabledForDeployment/EnabledForTemplateDeployment property run:
#
# New-AzureRmResourceGroup -Name KeyVaults -Location WestUS
# New-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName KeyVaults -Location WestUS -EnabledForDeployment -EnabledForTempalteDeployment
#
# Once the certificate is created and stored in the vault, the script will provide the parameter values needed for template deployment
View Test-MoveResources.ps1
#
#This script will call the validateMoveResources api to see if resources can be moved (before you try to actually move them)
#
$subscriptionId = '...'
$sourceResourceGroup = 'SourceGroup'
$destinationResourceGroup = 'DestGroup' #must exist
# Create an array of resourceIds that are to be moved
$resourcesToMove = @(
"/subscriptions/$subscriptionId/resourceGroups/$sourceResourceGroup/providers/Microsoft.Network/publicIPAddresses/somePublicIp"
@bmoore-msft
bmoore-msft / azuredeploy.json
Created Jun 27, 2017
AzureRM deployment template using listKeys on a storageAccount
View azuredeploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"storeName": "[concat('store', uniqueString(resourceGroup().id))]"
},
"resources": [
{
"name": "[variables('storeName')]",
@bmoore-msft
bmoore-msft / variableNicConfigs.json
Created Jun 13, 2017
Deploys 2 NICs in a copyLoop with different ipConfigurations
View variableNicConfigs.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": { },
"variables": {
"nicIPConfigurations": [
{
"privateIPAllocationMethod": "Dynamic",
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets/', 'vNet', 'Subnet-1')]"
View azuredeploy.json
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "Username for the Virtual Machine."
}
},
@bmoore-msft
bmoore-msft / New-KeyVaultForTemplateDeployment.ps1
Created Feb 22, 2016
Create an Azure KeyVault Enabled for Template Deployment (sh and ps)
View New-KeyVaultForTemplateDeployment.ps1
#Requires -Module AzureRM.Profile
#Requires -Module AzureRM.KeyVault
#Login and Select the default subscription if needed
#Login-AzureRmAccount
#Select-AzureRmSubscription -SubscriptionName 'subscription name'
#Change the values below before running the script
$VaultName = 'myvault' #Globally Unique Name of the KeyVault
$VaultLocation = 'East US' #Location of the KeyVault
You can’t perform that action at this time.