Skip to content

Instantly share code, notes, and snippets.

Avatar

Muhammad Faizan-ul-haq faizan002

View GitHub Profile
@faizan002
faizan002 / create_vault.ps1
Created Nov 13, 2017
Create a Vault In Azure to store password and retrieve it to use in Credentials object. (Powershell Azure automation)
View create_vault.ps1
$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 Nov 13, 2017
Calculate number of ResourceGroups with same prefix string in name. (Microsoft Azure - Powershell)
View NumberOfRG.ps1
$vmNamePrefix="SomeString"
$existingNumberOfRGs = $(Get-AzureRmResourceGroup | Where-Object {$_.ResourceGroupName -like "$vmNamePrefix*"}).count
$nextRGNumber = $existingNumberOfRGs + 1
$rgName = $rgNamePrefix + "$nextRGNumber"