Skip to content

Instantly share code, notes, and snippets.

View marckean's full-sized avatar

Marc Kean marckean

View GitHub Profile
{
"$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."
}
},
### 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": {
"vmName": {
"type": "string",
"metadata": {
"description": "Name of the VM"
}
},
$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
$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
{
"bindings": [
{
"name": "req",
"type": "httpTrigger",
"direction": "in",
"methods": [
"get"
],
"route": "austereo/{url}",
# 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
### Written with Azure PowerShell Module version 4.4.1
# Fill in the below variables
$SPDisplayName = 'User Account SP'
$SPPassword = 'password' # Password is required
$ResourceGroup = '' # Leave blank for subscription scope as to where to apply the SP role to
$Role = 'Contributor' # Could also be 'Owner'
Login-AzureRmAccount
### Choose Subscription
# 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
# This Sets up WinRM Remote PowerShell with delegated authentication while creating a self signed certificate
########################################################################
################ Do this on the Server
########################################################################
#Enable WinRM on a VM - with on-demand certificate creation
Function RemotePowerShell {
$process = 'cmd.exe'
$arguments = '/c winrm invoke restore winrm/config @{}'