Skip to content

Commit

Permalink
fix string casting
Browse files Browse the repository at this point in the history
  • Loading branch information
jpawlowski committed Mar 23, 2024
1 parent 639649a commit 4645a46
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Runbooks/Common_0002__Import-AzAutomationVariableToPSEnv.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ if ('AzureAutomation/' -eq $env:AZUREPS_HOST_ENVIRONMENT -or $PSPrivateMetadata.
[Environment]::SetEnvironmentVariable($_.Name, 'False')
}
}
elseif ([string]$_.Value.Length -gt 32767) {
elseif ([string]::new($_.Value).Length -gt 32767) {
Write-Verbose "[COMMON]: - SKIPPING $($_.Name) because it is too long"
}
elseif ([string]$_.Value -eq '') {
elseif ([string]::new($_.Value) -eq '') {
Write-Verbose "[COMMON]: - Setting `$env:$($_.Name) as empty string"
[Environment]::SetEnvironmentVariable($_.Name, "''")
}
else {
Write-Verbose "[COMMON]: - Setting `$env:$($_.Name)"
[Environment]::SetEnvironmentVariable($_.Name, [string]$_.Value)
[Environment]::SetEnvironmentVariable($_.Name, [string]::new($_.Value))
}
}
}
Expand Down

0 comments on commit 4645a46

Please sign in to comment.