Skip to content

Commit 432ee87

Browse files
authored
Update Module Names in DiskEncryption setup
Change requires, since all the commands have already been changed to Az modules Remove attempts at version sniffing, because there are no old versions of the Az.* modules
1 parent b96017c commit 432ee87

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

src/Compute/Compute/Extension/AzureDiskEncryption/Scripts/AzureDiskEncryptionPreRequisiteSetup.ps1

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#Requires -Module AzureRM.Resources
2-
#Requires -Module AzureRM.KeyVault
1+
#Requires -Module Az.Resources
2+
#Requires -Module Az.KeyVault
33

44
Param(
55
[Parameter(Mandatory = $true,
@@ -52,8 +52,6 @@ $ErrorActionPreference = "Stop"
5252
# Section2: Create AAD app if encryption is enabled using AAD. Fill in $aadClientSecret variable if AAD app was already created.
5353
####################################################################################################################################
5454

55-
$azureResourcesModule = Get-Module 'AzureRM.Resources';
56-
5755
if($aadAppName)
5856
{
5957
# Check if AAD app with $aadAppName was already created
@@ -68,15 +66,8 @@ $ErrorActionPreference = "Stop"
6866
$aadClientSecret = [Guid]::NewGuid().ToString();
6967
Write-Host "Creating new AAD application ($aadAppName)";
7068

71-
if($azureResourcesModule.Version.Major -ge 5)
72-
{
73-
$secureAadClientSecret = ConvertTo-SecureString -String $aadClientSecret -AsPlainText -Force;
74-
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $secureAadClientSecret;
75-
}
76-
else
77-
{
78-
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $aadClientSecret;
79-
}
69+
$secureAadClientSecret = ConvertTo-SecureString -String $aadClientSecret -AsPlainText -Force;
70+
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $secureAadClientSecret;
8071

8172
$servicePrincipal = New-AzADServicePrincipal -ApplicationId $ADApp.ApplicationId;
8273
$SvcPrincipals = (Get-AzADServicePrincipal -SearchString $aadAppName);
@@ -250,12 +241,6 @@ foreach($vm in $allVMs)
250241
}
251242
else
252243
{
253-
if($azureResourcesModule.Version.Major -lt 6)
254-
{
255-
Write-Error "Please specify AAD application details, or install AzurePowershell version 6.0.0.0 or above to use AzureDiskEncryption without AAD";
256-
return;
257-
}
258-
259244
if(-not $kek)
260245
{
261246
Set-AzVMDiskEncryptionExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -VolumeType 'All';

0 commit comments

Comments
 (0)