troubleshooting Question

Convert PS variables to Parameters

Avatar of Jay Thomas
Jay ThomasFlag for United Kingdom of Great Britain and Northern Ireland asked on
Powershell
6 Comments1 Solution59 ViewsLast Modified:
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;

##############################################
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros