1
- # Requires -Module AzureRM .Resources
2
- # Requires -Module AzureRM .KeyVault
1
+ # Requires -Module Az .Resources
2
+ # Requires -Module Az .KeyVault
3
3
4
4
Param (
5
5
[Parameter (Mandatory = $true ,
@@ -52,8 +52,6 @@ $ErrorActionPreference = "Stop"
52
52
# Section2: Create AAD app if encryption is enabled using AAD. Fill in $aadClientSecret variable if AAD app was already created.
53
53
# ###################################################################################################################################
54
54
55
- $azureResourcesModule = Get-Module ' AzureRM.Resources' ;
56
-
57
55
if ($aadAppName )
58
56
{
59
57
# Check if AAD app with $aadAppName was already created
@@ -68,15 +66,8 @@ $ErrorActionPreference = "Stop"
68
66
$aadClientSecret = [Guid ]::NewGuid().ToString();
69
67
Write-Host " Creating new AAD application ($aadAppName )" ;
70
68
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 ;
80
71
81
72
$servicePrincipal = New-AzADServicePrincipal - ApplicationId $ADApp.ApplicationId ;
82
73
$SvcPrincipals = (Get-AzADServicePrincipal - SearchString $aadAppName );
@@ -250,12 +241,6 @@ foreach($vm in $allVMs)
250
241
}
251
242
else
252
243
{
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
-
259
244
if (-not $kek )
260
245
{
261
246
Set-AzVMDiskEncryptionExtension - ResourceGroupName $vm.ResourceGroupName - VMName $vm.Name - DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl - DiskEncryptionKeyVaultId $keyVaultResourceId - VolumeType ' All' ;
0 commit comments