Skip to content

Instantly share code, notes, and snippets.

View faizan002's full-sized avatar

Muhammad Faizan-ul-haq faizan002

View GitHub Profile
@faizan002
faizan002 / create_vault.ps1
Created November 13, 2017 10:31
Create a Vault In Azure to store password and retrieve it to use in Credentials object. (Powershell Azure automation)
$password="super secret value"
$VaultName="SomeName"
$KeyName="KeyToStorePassword"
$ResourceGrpName="MyExistingResourceGroupName"
$loc="chose a valid value"
New-AzureRmKeyVault -VaultName $VaultName -ResourceGroupName $ResourceGrpName -Location $loc # (This creates a vault)
$PasswordAsSecureString = ConvertTo-SecureString -String $password -AsPlainText -Force
Set-AzureKeyVaultSecret -VaultName $VaultName -Name $KeyName -SecretValue $PasswordAsSecureString
@faizan002
faizan002 / NumberOfRG.ps1
Last active November 13, 2017 10:21
Calculate number of ResourceGroups with same prefix string in name. (Microsoft Azure - Powershell)
$vmNamePrefix="SomeString"
$existingNumberOfRGs = $(Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like "$vmNamePrefix*"}).count
$nextRGNumber = $existingNumberOfRGs + 1
$rgName = $rgNamePrefix + "$nextRGNumber"