GcpFunctions.ps1
Function CleanUpGcpDisk([string]$gcpServiceAccountKeyFile, [string]$cloudDiskName) { $gcpServiceAccountKey = Get-Content -Raw -Path $gcpServiceAccountKeyFile | ConvertFrom-Json try { $disk = Get-GceImage -Name $cloudDiskName -Project $gcpServiceAccountKey.project_id } catch { if ($_.exception.Message -like '*The resource *was not found*') { return } ThrowError ([UploaderError]::new("Error finding disk image '$cloudDiskName'", $_.Exception)) } Log "Deleting existing disk image '$cloudDiskName'" Remove-GceImage -Name $cloudDiskName -Project $gcpServiceAccountKey.project_id } |