Skip to content

Instantly share code, notes, and snippets.

@machv
machv / README.md
Last active January 19, 2021 16:53

Azure Automation Account / Monthly deployment schedules

Configuration options

To set how far in the future (in months) to prepare deployment rings set variable $monthsToProvision

To set deployment rings populate tags to $deploymentRings hash table in format

<TagName> = <Time-Span for delayed deployment>

Install

New-AzRoleDefinition -InputFile rbac.json

Root management group

If you want to link Custom role to the top most root management group (that is always available), use an ID that corresponds with AAD Tenant ID GUID.

FYI

function Invoke-AzVMDiskSnapshot {
param(
[Parameter(Mandatory = $true)]
[string]$VMResourceGroupName,
[Parameter(Mandatory = $true)]
[string]$VMName,
[string]$SnapshotsResourceGroupName = $null
[bool]$Shutdown = $true
)
@machv
machv / README.md
Last active February 23, 2022 15:40
Packer for Debian with Hyper-V "SSH Direct" fixes

Packer template for Debian with "SSH Direct" on Hyper-V

Output of this Packer template is Hyper-V Gen2 VM with Debian 10 that supports direct connection via vsock thus no internet connectivity is needed.

How to build

$key = "$env:USERPROFILE\.ssh\lab01_rsa"
$publicKey = Get-Content "$($key).pub"
@machv
machv / site-to-site.tf
Last active June 24, 2020 15:33
Terraform script to deploy Site-to-site IPSec demo in Azure
locals {
ike_secret = "tajneheslo"
# Azure site
ip_azure_range = "10.10.0.0/16"
ip_azure_subnet_main = "10.10.0.0/24"
ip_azure_subnet_gw = "10.10.255.240/28"
asn_azure = "65010"
# On-premises site
@machv
machv / flow.md
Created June 9, 2020 13:17
RC -> Datum narozeni (PowerAutomate)

Clean RC expression

Type: Data Operation Action: Compose

Expression:

replace(replace(outputs('RC'), '/', ''), ' ', '')

Datum narozeni expression

#region create AAD app
# based on https://docs.microsoft.com/en-us/powershell/partnercenter/secure-app-model?view=partnercenterps-1.5
$DisplayName = "MFA Status Ingester"
Connect-AzureAD
$adAppAccess = [Microsoft.Open.AzureAD.Model.RequiredResourceAccess]@{
ResourceAppId = "00000002-0000-0000-c000-000000000000";
ResourceAccess =
[Microsoft.Open.AzureAD.Model.ResourceAccess]@{
@machv
machv / new-vm.ps1
Last active April 21, 2022 07:54
vm ps
$vmRootDir = "D:\Virtual Machines"
$LibraryPath = "C:\Data\Parent Disks"
$vSwitchName = "VM"
$MountDir = "C:\Data\MountDir" #cannot be CSV
$ServerName = ""hv01
$VMs = @()
$VMs += @{
VMName = "VM01"
MemoryStartupBytes = 512MB
https://support.microsoft.com/en-us/help/4561494/microsoft-edge-application-creation-fails-in-configuration-manager
@machv
machv / script.ps1
Created May 14, 2020 10:10
reg2xml
<# Added by Michael Pietroforte #>
Param(
[Parameter(Mandatory=$True)][string]$regPath,
[Parameter(Mandatory=$True)][string]$xmlPath
)
<#
Orginal script by Malcolm McCaffery
More info at the http://chentiangemalc.wordpress.com/2014/07/02/importing-reg-files-into-group-policy-preferences/
#>