Skip to content

Replace [string]::IsNullOrEmpty with -not in Azure storage cmdlets (#870)#913

Merged
FH-Inway merged 4 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/870-isnullorempty-azure-storage
Jul 18, 2026
Merged

Replace [string]::IsNullOrEmpty with -not in Azure storage cmdlets (#870)#913
FH-Inway merged 4 commits into
d365collaborative:masterfrom
pavankadabala-png:fix/870-isnullorempty-azure-storage

Conversation

@pavankadabala-png

Copy link
Copy Markdown
Contributor

Applies the [string]::IsNullOrEmpty-not quick-win from #870 (suggested by @FriedrichWeinmann) to the Azure storage cmdlets.

For a string operand, [string]::IsNullOrEmpty($x) is equivalent to -not $x, so this replaces the more verbose form:

# before
if (([string]::IsNullOrEmpty($AccountId) -eq $true) -or
    ([string]::IsNullOrEmpty($Container)) -or
    (([string]::IsNullOrEmpty($AccessToken)) -and ([string]::IsNullOrEmpty($SAS)))) {

# after
if ((-not $AccountId) -or
    (-not $Container) -or
    ((-not $AccessToken) -and (-not $SAS))) {

Files

  • Get-D365AzureStorageFile
  • Get-D365AzureStorageUrl
  • Invoke-D365AzureStorageDownload
  • Invoke-D365AzureStorageUpload

Notes

  • Every operand here is a [string] parameter, so -not and [string]::IsNullOrEmpty are equivalent — they only differ for non-string values such as 0 or $false. I kept the original parentheses/grouping so the boolean logic is unchanged.
  • Scope: limited to the Azure storage cmdlets @FriedrichWeinmann referenced. The same simplification applies to other string-parameter checks across the module — happy to follow up in a separate PR. I intentionally left sites where the operand is an object or external-command output (e.g. Get-MpComputerStatus, & $executable ...) unchanged, since -not is not equivalent there.

Refs #870

@pavankadabala-png pavankadabala-png changed the title Fix/870 isnullorempty azure storage Replace [string]::IsNullOrEmpty with -not in Azure storage cmdlets (#870) Jul 13, 2026
@FH-Inway
FH-Inway merged commit 1d082fe into d365collaborative:master Jul 18, 2026
5 checks passed
@FH-Inway

Copy link
Copy Markdown
Member

@pavankadabala-png Thanks for the contribution, looks good. Would be great if you could follow up for other string parameter checks.

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.

2 participants