Skip to content

Instantly share code, notes, and snippets.

View marckean's full-sized avatar

Marc Kean marckean

View GitHub Profile
# --------------------------------------------------------------------------------------------------------------
#  Title         : Azure - Azure VM enable guest level monitoring 
#  Written by  : Marc Kean
#  Date          : December, 2017
# --------------------------------------------------------------------------------------------------------------
#
# Script to turn on guest OS level monitoring across all VMs in a subscription. This will work its way through all
# ARM based Azure VMs one by one. VMs need to be turned on, otherwise they can't be enabled. Run again over and over
# Recently tested fully with a later version of the Azure PowerShell module - Install-Module AzureRM -RequiredVersion 4.4.1
#region Logon to Azure
Login-AzureRmAccount
$subscription = Get-AzureRmSubscription | Out-GridView -PassThru
Select-AzureRmSubscription -SubscriptionId $subscription.Id
#endregion
# Variables for YOu to fill in
# Recently tested fully with a later version of the Azure PowerShell module - Install-Module AzureRM -RequiredVersion 4.4.1
#region Logon to Azure
Login-AzureRmAccount
$subscription = Get-AzureRmSubscription | Out-GridView -PassThru
Select-AzureRmSubscription -SubscriptionId $subscription.Id
#endregion
# Variables for YOu to fill in
# Setup the Azure Functions parameters
switch -RegEx ($REQ_QUERY_URL)
{
\S {$url = $REQ_QUERY_URL}
default {$url = "http://legacy.scahw.com.au/$REQ_PARAMS_URL.xspf"}
}
# Invoke the web request to the URL
$iwr = Invoke-RestMethod -Uri $url
{
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get"
],
"route": "austereo/{url}",
$net1 = new-object -ComObject WScript.Network
$net2 = new-object -ComObject Shell.Application
 
$net1.RemoveNetworkDrive("m:", $True, $True)
Start-Sleep -Seconds 2
$net1.MapNetworkDrive("m:", "\\<StorageAccountName>.file.core.windows.net\music", $true, "<StorageAccountName>", "<StorageAccountKey>")
$net2.NameSpace('m:').Self.Name = "Drive 1 Label"
$net1.RemoveNetworkDrive("n:", $True, $True)
Start-Sleep -Seconds 2
$ShedService = New-Object -comobject 'Schedule.Service'
$ShedService.Connect()
$Task = $ShedService.NewTask(0)
$Task.RegistrationInfo.Description = 'M-Drive Mapping'
$Task.Settings.Enabled = $true
$Task.Settings.AllowDemandStart = $true
$trigger = $task.triggers.Create(9)
$trigger.Enabled = $true
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
### Log into Azure
Add-AzureRmAccount
$Subscription = (Get-AzureRmSubscription | Out-GridView -Title "Choose a Source & Target Subscription ..." -PassThru)
Select-AzureRmSubscription -SubscriptionId $Subscription.Id
# Upload Certificate to Azure's Key Vault
$securepfxpwd = ConvertTo-SecureString –String 'password' –AsPlainText –Force # Password for the private key PFX certificate
$certificateName = 'My-Cert'
$vaultName = 'MyVault'
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"metadata": {
"description": "User name for the Virtual Machine."
}
},