Skip to content

Instantly share code, notes, and snippets.

@mrik23
mrik23 / RandomPasswordGenerator.ps1
Created November 6, 2017 11:09
A basic PowerShell script to generate in bulk random passwords with specific formulation.
#Number of passwords to generate
$numberOfPasswords = 10
#Password formulation
$passwordLength = 9
$minimumNumericCharacters = 2
$caps = $true
$specials = $false
#Password characters sets
@mrik23
mrik23 / boxstarter1.txt
Created September 14, 2017 06:12
Test Boxstarter
choco install googlechrome
choco install firefox
choco install jre8
choco install flashplayerplugin
choco install 7zip.install
choco install notepadplusplus.install
choco install vlc
choco install paint.net
@mrik23
mrik23 / AzureRM-CreateVmDiskEncryptionEnabled.ps1
Last active July 9, 2018 19:30
This PowerShell script create a new VM and enable disk encryption. Necessary components like Azure AD app and Key Vault are also created.
#Azure PowerShell v2
#Check documentation https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0
Import-Module AzureRM
$credential = Get-Credential
Login-AzureRmAccount -Credential $credential
#Set variables
$location = "eastus" #Find the choice of location with 'Get-AzureRmLocation | select location'
$rgName = "myResourceGroup" + (Get-Random -Maximum 99).ToString()
@mrik23
mrik23 / AzureRM-RegisterServiceProvider.ps1
Created August 5, 2017 04:59
A simple PowerShell script using Azure PowerShell to check the registration of a service provider and register it.
#Azure PowerShell v2
#Check documentation https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0
Import-Module AzureRM
$credential = Get-Credential
Login-AzureRmAccount -Credential $credential
#List all resource providers enabled
Get-AzureRmResourceProvider -ListAvailable | format-table
@mrik23
mrik23 / AzureRM-ChangeVMOSDiskHostCaching.ps1
Last active August 6, 2017 02:57
PowerShell snippet to change the Host Caching option for the OS disk of an existing VM in Azure RM.
#Requires Azure PowerShell v2
#Check documentation https://docs.microsoft.com/en-us/powershell/azure/active-directory/install-adv2?view=azureadps-2.0
#Make sure AzureRM module is installed and loaded
Import-Module AzureRM
#Connect to Azure
Login-AzureRmAccount
#Get the current VM config
@mrik23
mrik23 / MSOL-BulkRemoveDirectAssignedLicense.ps1
Last active June 7, 2023 04:23
Remove in bulk direct assigned license to users who have group assigned license with Azure AD PowerShell v1
<#
Modified version of the script from Microsoft Documentation.
Removed the part that checks if the users is assigned more products than the group assigned license.
Added connection part and help to find Sku and Group Object ID.
This script requires Azure AD (aks MSOL) PowerShell v1. It doesn't seem possible to do so with v2.
Ref: https://docs.microsoft.com/en-us/azure/active-directory/active-directory-licensing-ps-examples
#>
Import-Module MSOnline
$UserCredential = Get-Credential
@mrik23
mrik23 / deployarmtemplate.sh
Created July 2, 2017 15:27
Deploy ARM template with Azure CLI 2.0
# Connect to Azure
az login
# Create resource group if necessary
az group create --name MyResourceGroup --location "Central US"
# Deploy the template to the defined resource group
az group deployment create \
--name DeploymentFromCLI \
--resource-group MyResourceGroup \
@mrik23
mrik23 / deployarmtemplate.ps1
Created July 2, 2017 15:12
Deploy ARM template with PowerShell
#Connect to Azure
Login-AzureRmAccount
#Create a new resource group is necessary
New-AzureRmResourceGroup -Name MyResourceGroup -Location "East US"
#Deploy the template in the defined Resource Group
New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName MyResourceGroup `
-TemplateFile c:\projects\templates\azuredeploy.json `
-Verbose
@mrik23
mrik23 / arm_template_with_functions_2.json
Last active July 2, 2017 13:47
Example ARM template with functions 2
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccountType": {
"type": "string"
}
},
"variables": {
"storageAccountName": "[concat('sa', uniquestring(resourceGroup().id))]"
@mrik23
mrik23 / arm_template_with_functions.json
Last active July 2, 2017 11:50
Example ARM Template with functions
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"resources": [
{
"apiVersion": "2016-01-01",
"type": "Microsoft.Storage/storageAccounts",
"name": "[concat('storage', copyIndex(), uniqueString(resourceGroup().id))]",
"location": "[resourceGroup().location]",
"sku": {