Export/Private/Set-StorageTableSetupDone.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
28
29
30
31
32
33
34
35
36
37
function Global:Set-StorageTableSetupDone {
    <#
    .SYNOPSIS
    ...
     
    .EXAMPLE
    ...
    #>

    [CmdletBinding()]
    param
    (
        [Parameter(Mandatory = $true)]
        [string]
        $ResourceGroupName,
        [Parameter(Mandatory = $true)]
        [string]
        $StorageAccountName,        
        [Parameter(Mandatory = $true)]
        [string]
        $StorageTableNameSetup
    )
    process {
        Write-Verbose "Removing 'SetupNotDone'-entry from storage table $StorageTableNameSetup to indicate that the setup is done now"
        $storageAccount = Get-AzStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName
        $storageAccountContext = $storageAccount.Context
        $storageAccountTable = Get-AzStorageTable -Name $StorageTableNameSetup -Context $storageAccountContext.Context
        $cloudTable = $storageAccountTable.CloudTable
        #$rows = Get-AzTableRow -Table $cloudTable | Where-Object { ($_.Command -eq 'SetupNotDone') }
        $row = Get-AzTableRow -Table $cloudTable | Where-Object { ($_.Command -eq 'SetupNotDone') } | Select-Object -First 1
        #foreach ($row in $rows) {
        if ($row){
            Remove-AzTableRow -Table $cloudTable -entity $row | Out-Null
            Write-Verbose "Entry removed"
        }
        #}
    }
}