Skip to content

Instantly share code, notes, and snippets.

Avatar

Sean McDonnell seanmcdonnellblog

View GitHub Profile
View Invoke-RestMethod.ps1
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[String] $appID,
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string] $appSecret,
[Parameter(Mandatory=$true, ValueFromPipeline=$true)]
[string] $subID
View Azure-KeyVault-SP-GetList-Access.ps1
<#
.DESCRIPTION
This script will create or use an Existing Key Vault, followed by adding 3 secrets for a service principal
- ClientID
- ClientSecret
- TenantID
Once the key vault is created, the service principal is provided Get and List permissions to fetch the keys.
.PARAMETER -keyVaultName
The name of the existing or new Key Vault
.PARAMETER -Location
View Az-Graph-StorageTags.ps1
## EXAMPLE 1 - Find tags for Storage Accounts
$resourceType = 'microsoft.storage/storageAccounts'
$query = "where type =~ '$resourceType' | project name, resourceGroup, type, location, tags"
Search-AzGraph -Query $query
View install-Az-Graph-Module.ps1
# Install the PowerShell Module
Install-Module -Name Az.ResourceGraph
# Get Commands
Get-Command -Module ‘Az.ResourceGraph'
# Get Help with Examples
Get-Help Search-AzGraph -Examples
View Azure-ResourceGraph-Storage.ps1
# Global Variables
$resourceType = 'microsoft.storage/storageAccounts'
## EXAMPLE 1 - Find tags for Storage Accounts
$query = "where type =~ '$resourceType' | project name, resourceGroup, type, location, tags"
Search-AzGraph -Query $query
## EXAMPLE 2 - Display Count for the Service Tag
$query = "where type =~ '$resourceType' | project tag = tostring(tags.Service) | summarize count() by tag"
Search-AzGraph -Query $query
@seanmcdonnellblog
seanmcdonnellblog / Install-Pulumi.cmd
Created July 11, 2019 20:17
Install Pulumi on Windows 10
View Install-Pulumi.cmd
@"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; iex ((New-Object System.Net.WebClient).DownloadString('https://get.pulumi.com/install.ps1'))" && SET "PATH=%PATH%;%USERPROFILE%\.pulumi\bin"
@seanmcdonnellblog
seanmcdonnellblog / Server_Shutdown_Startup.ps1
Last active August 10, 2020 13:44
Connects to Azure and stops of all VMs in parallel for the scheduled resource group using tags
View Server_Shutdown_Startup.ps1
<#
.SYNOPSIS
Connects to Azure and stops of all VMs in parallel for the scheduled resource group
.DESCRIPTION
This runbook connects to Azure and stops all ARM Azure VMs within a resource group
You should attach a schedule to this runbook to run it at a specific time.
REQUIRED AUTOMATION ASSETS
1. An Automation variable asset called "SubscriptionId" that contains the GUID for this Azure subscription.
To use an asset with a different name you can pass the asset name as a runbook input parameter or change the default value for the input parameter.
2. An Automation credential asset called "AzureCred" that contains the Azure AD user credential with authorization for this subscription.
@seanmcdonnellblog
seanmcdonnellblog / GitInit.ps1
Last active December 5, 2018 23:57
GIT Init and Sync
View GitInit.ps1
# Initialise the local GIT repository (Needs to be run from the repository directory
git init
# You should see the following output "Initialized empty Git repository in C:/users/user/source/repos/.git/"
# Run the follow command to show the hidden Git file. This tracks any changes made to the repository
dir -ah
# To sync to the Azure DevOps Project, use the HTTPs push command found in your Azure DevOps Project under "Repos"
git remote add origin https://xxxxxx@dev.azure.com/xxxxxx/IaaSv1/_git/Blog
git push -u origin --all