Azure / Azure/Azure-Network-Security

Get-DanglingDnsRecords fails with: Attempted to divide by zero

Open
#389 3 comments 1 reaction 2 assignees Claimed by @tanviohri View on GitHub
Dominant language
PowerShell
Stars
942
Forks
360
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When running Get-DanglingDnsRecords with the switch '-FetchDnsRecordsFromAzureSubscription' using a service connection through Azure DevOps we see the error: 'Attempted to divide by zero' for multiple customers, but not everyone.

**Reproduce**

Create a pipeline to run the code from using a Service connection with full read permissions on the intermediate management group in Azure.

It should use the 'FetchDnsRecordsFromAzureSubscription' switch to do so.

**Expected behavior**

We expect it to output a hash table and CSV-files, as this works as expected when running it locally.

**Screenshots**

```

VERBOSE: Exporting function 'New-AzResourceGraphQuery'.
VERBOSE: Exporting function 'Remove-AzResourceGraphQuery'.
VERBOSE: Exporting function 'Update-AzResourceGraphQuery'.
VERBOSE: Exporting function 'Test-DotNet'.
VERBOSE: Exporting function 'Preload-Assembly'.
VERBOSE: Exporting cmdlet 'Search-AzGraph'.
VERBOSE: Importing cmdlet 'Search-AzGraph'.
VERBOSE: Importing function 'Get-AzResourceGraphQuery'.
VERBOSE: Importing function 'New-AzResourceGraphQuery'.
VERBOSE: Importing function 'Remove-AzResourceGraphQuery'.
VERBOSE: Importing function 'Update-AzResourceGraphQuery'.
VERBOSE: Sent top=100 skip=0 skipToken=
VERBOSE: Received results: 1
Get-DanglingDnsRecords: /agent/_work/1/s/management/src/powershell/private/Get-DanglingCNameRecord.ps1:21
Line |
21 | … rdsOutput = Get-DanglingDnsRecords -FetchDnsRecordsFromAzureSubscript …
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Attempted to divide by zero.

##[error]PowerShell exited with code '1'.
##[error]PowerShell wrote one or more lines to the standard error stream.
```

**Environment- if applicable**
```
Task : Azure PowerShell
Description : Run a PowerShell script within an Azure environment
Version : 5.243.7

```

**Logs- if applicable**

**Additional context**

The weird part it, that we've seen it working, and we've seen it failing (mostly fail). It seems to be some unhandled logic in the code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.