Skip to content

Update the module names in AzureDiskEncryptionPreRequisiteSetup.ps1 #8618

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 26, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Requires -Module AzureRM.Resources
#Requires -Module AzureRM.KeyVault
#Requires -Module Az.Resources
#Requires -Module Az.KeyVault

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

$azureResourcesModule = Get-Module 'AzureRM.Resources';

if($aadAppName)
{
# Check if AAD app with $aadAppName was already created
Expand All @@ -68,15 +66,8 @@ $ErrorActionPreference = "Stop"
$aadClientSecret = [Guid]::NewGuid().ToString();
Write-Host "Creating new AAD application ($aadAppName)";

if($azureResourcesModule.Version.Major -ge 5)
{
$secureAadClientSecret = ConvertTo-SecureString -String $aadClientSecret -AsPlainText -Force;
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $secureAadClientSecret;
}
else
{
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $aadClientSecret;
}
$secureAadClientSecret = ConvertTo-SecureString -String $aadClientSecret -AsPlainText -Force;
$ADApp = New-AzADApplication -DisplayName $aadAppName -HomePage $defaultHomePage -IdentifierUris $identifierUri -StartDate $now -EndDate $oneYearFromNow -Password $secureAadClientSecret;

$servicePrincipal = New-AzADServicePrincipal -ApplicationId $ADApp.ApplicationId;
$SvcPrincipals = (Get-AzADServicePrincipal -SearchString $aadAppName);
Expand Down Expand Up @@ -250,12 +241,6 @@ foreach($vm in $allVMs)
}
else
{
if($azureResourcesModule.Version.Major -lt 6)
{
Write-Error "Please specify AAD application details, or install AzurePowershell version 6.0.0.0 or above to use AzureDiskEncryption without AAD";
return;
}

if(-not $kek)
{
Set-AzVMDiskEncryptionExtension -ResourceGroupName $vm.ResourceGroupName -VMName $vm.Name -DiskEncryptionKeyVaultUrl $diskEncryptionKeyVaultUrl -DiskEncryptionKeyVaultId $keyVaultResourceId -VolumeType 'All';
Expand Down