Skip to content

Instantly share code, notes, and snippets.

@vermashi
vermashi / RetreiveEncryptionSecretViaUrlV2.ps1
Last active August 29, 2019 18:48
Retrieve Encryption key via secret URL Version 2 (for Az cmdlets)
Param(
[Parameter(Mandatory = $true,
HelpMessage="URL to the secret stored in the keyvault")]
[ValidateNotNullOrEmpty()]
[string]$secretUrl,
[Parameter(Mandatory = $true,
HelpMessage="URL to the KEK, can be empty")]
[AllowEmptyString()]
[string]$kekUrl,
@vermashi
vermashi / RetreiveEncryptionSecretViaUrl.ps1
Last active May 4, 2021 21:34
Retrieve Encryption key via secret URL
Param(
[Parameter(Mandatory = $true,
HelpMessage="URL to the secret stored in the keyvault")]
[ValidateNotNullOrEmpty()]
[string]$secretUrl,
[Parameter(Mandatory = $false,
HelpMessage="URL to the KEK")]
[ValidateNotNullOrEmpty()]
[string]$kekUrl,
@vermashi
vermashi / FormatLinuxDisksLVM.sh
Last active August 28, 2018 20:19
Format the data disks with LVM in an azure linux VM
#!/usr/bin/env bash
set -x
pvcreate -f /dev/disk/azure/scsi1/lun1
vgcreate vg0 /dev/disk/azure/scsi1/lun1
lvcreate -l100%FREE -n lv0 vg0
echo "y" | mkfs.ext4 /dev/mapper/vg0-lv0
mkdir /data1
echo "/dev/mapper/vg0-lv0 /data1 ext4 defaults,nofail 0 0" >>/etc/fstab
@vermashi
vermashi / FormatLinuxDisks.sh
Last active August 14, 2018 02:34
Format the data disks in an azure linux VM
#!/usr/bin/env bash
set -x
if ! [ -x "$(command -v curl)" ]; then
echo 'Error: curl not installed, script cannot run' >&2
exit 1
fi
echo "y" | mkfs.ext4 /dev/disk/azure/scsi1/lun1
mkdir /data1
echo "/dev/disk/azure/scsi1/lun1 /data1 ext4 defaults,nofail 0 0" >>/etc/fstab
mount -a
@vermashi
vermashi / FormatMBRDisk.ps1
Created August 13, 2018 23:48
Format all uninitialized disks with an MBR partition table and an NTFS partition
$sizeInBytes = (((16 * 1024) * 1024) * 1024) - 1
Get-Disk | Where-Object PartitionStyle -eq "RAW" | Where-Object Size -gt $sizeInBytes | Initialize-Disk -PartitionStyle MBR -Confirm:$False -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -Confirm:$False
@vermashi
vermashi / RetreiveEncryptionSecretOfVM.ps1
Created April 20, 2018 01:06
Retrieve the encryption secret (aka passphrase) from Azure Key Vault
Param(
[Parameter(Mandatory = $true,
HelpMessage="ResourceGroup name of the vm")]
[ValidateNotNullOrEmpty()]
[string]$rgName,
[Parameter(Mandatory = $true,
HelpMessage="VM name")]
[ValidateNotNullOrEmpty()]
[string]$vmName,