Skip to content

Conversation

@Omkar-Mohite96
Copy link
Contributor

This remediation script helps to enable encryption at host property for virtual machine scale sets and virtual machines on subscription. In case, after executing script, if you want to rollback the changes, you can rollback the earlier changes.

3. Take a backup of these non-compliant resource types.
4. Register 'Microsoft.Security' provider and enable Azure Defender plan for all non-compliant resource types for subscription.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

@Omkar-Mohite96 Omkar-Mohite96 Apr 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already this line removed

# Command to execute:
Examples:
1. Run below command to configure Azure Defender for subscription

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

azure defender ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

}

Write-Host $([Constants]::SingleDashLine)
$VirtualMachines = Get-AzVM -ResourceGroupName $ResourceGroupName

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the control logic, we are not considering all VM's, only VMSS and underlying VMs when the orchestration mode is flexible. BRS should be aligned with the control logic

<##########################################
# Overview:
This script is used to Enable Encryption at Host for Virtual machine scale sets and Virtual machines.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make the comment more illustrated like - and underlying Virtual Machines in flexible mode

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated comment

# Safe Check: Current user needs to be either Contributor or Owner for the subscription
$currentLoginRoleAssignments = Get-AzRoleAssignment -SignInName $currentSub.Account.Id -Scope "/subscriptions/$($SubscriptionId)";

if (($currentLoginRoleAssignments | Where { $_.RoleDefinitionName -eq "Owner" -or $_.RoleDefinitionName -eq 'Contributor' -or $_.RoleDefinitionName -eq "Security Admin" } | Measure-Object).Count -le 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you check for security admin role ? as this is role is not mentioned in the comments

"InitCommand": "Enable-EncrytionAtHost",
"RollbackMetadata": {
"RollbackCommand": "Disable-EncrytionAtHost",
"Arguments": ["SubscriptionId", "Path"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why Path is needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's file path, where we backup the remediated resources list in .json file.
SO, when user want to rollback the operations, user need to give file Path as argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants