Framework/Core/FixControl/Services/ContainerRegistryFix.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Set-StrictMode -Version Latest 

class ContainerRegistryFix: FixServicesBase
{       
    [PSObject] $ResourceObject = $null;

    ContainerRegistryFix([string] $subscriptionId, [ResourceConfig] $resourceConfig, [string] $resourceGroupName): 
        Base($subscriptionId, $resourceConfig, $resourceGroupName) 
    { }

    [MessageData[]] DisableAdminAccount([PSObject] $parameters)
    {
        [MessageData[]] $detailedLogs = @();
        
        $detailedLogs += [MessageData]::new("Disabling admin account for Container Registry [$($this.ResourceName)]...");
        $result = Update-AzureRmContainerRegistry `
                    -ResourceGroupName $this.ResourceGroupName `
                    -Name $this.ResourceName `
                    -DisableAdminUser `
                    -ErrorAction Stop

        $detailedLogs += [MessageData]::new("Admin account has been disabled for Container Registry [$($this.ResourceName)]", $result);
        
        return $detailedLogs;
    }
}