Avatar of Jay Thomas
Jay Thomas
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Convert PS variables to Parameters

Hi all,

I have a small PS script which i downloaded to encrypt VMs which works just fine. I have defined variables which work. I'd like not to have to hardcode the variables, instead, when I run the script I'd like to be asked to input them. I know I can do this with parameters but find the search results confusing as there appears to be several types of parameter types. Also, the command at the bottom of the script would surely fail because it is still looking for the variables. Is this a big job to accomplish? Thanks you for looking.

###########################################
$rgName = 'MySecureRg';
 $vmName = 'MySecureVM';
 $KeyVaultName = 'MySecureVault';
 $KeyVault = Get-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName $rgname;
 $diskEncryptionKeyVaultUrl = $KeyVault.VaultUri;
 $KeyVaultResourceId = $KeyVault.ResourceId;

 Set-AzureRmVMDiskEncryptionExtension -ResourceGroupName $rgname -VMName $vmName -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $KeyVaultResourceId;

##############################################
Powershell

Avatar of undefined
Last Comment
oBdA

8/22/2022 - Mon