Closed i5513 closed 7 months ago
This was fixed in 1.4.4 versión. Closing the issue
What is the difference between
@($a)
And
if($a) { @($a) } else {@()}
?
Thank you!
Actually, it's not really fixed as simply outputting the @() in a statement would generate the "null" output, hence I need to update this to something similar as:
$Win32AppRelationshipsTable = [ordered]@{
"relationships" = if ($Dependencies1) { @($Dependencies1) } else { , @() }
}
I will be adding that shortly.
Actually, it's not really fixed as simply outputting the @() in a statement would generate the "null" output, hence I need to update this to something similar as:
$Win32AppRelationshipsTable = [ordered]@{ "relationships" = if ($Dependencies1) { @($Dependencies1) } else { , @() } }
I will be adding that shortly.
Actually (with powershell 5.1), @() works as proposed in our commits (And ", @()" generate a different, not wanted output):
PS C:\> $a = [ordered]@{ a = @() }
PS C:\> $a | ConvertTo-Json
{
"a": [
]
}
PS C:\> $a = [ordered]@{ a = ,@() }
PS C:\> $a | ConvertTo-Json
{
"a": [
[
]
]
}
Maybe with powershell 7 change it ?
Thank you
Sorry for reopening, it is not necessary, of course, closing
Actually, it's not really fixed as simply outputting the @() in a statement would generate the "null" output, hence I need to update this to something similar as:
$Win32AppRelationshipsTable = [ordered]@{ "relationships" = if ($Dependencies1) { @($Dependencies1) } else { , @() } }
I will be adding that shortly.
Actually (with powershell 5.1), @() works as proposed in our commits (And ", @()" generate a different, not wanted output):
PS C:\> $a = [ordered]@{ a = @() } PS C:\> $a | ConvertTo-Json { "a": [ ] } PS C:\> $a = [ordered]@{ a = ,@() } PS C:\> $a | ConvertTo-Json { "a": [ [ ] ] }
Maybe with powershell 7 change it ?
Thank you
Well my commit was bad ... it should maintain the if
I tested :
# $b is not defined (or $null)
$a = @($b) ; $a | convertto-json
$a = @() ; $a | convertto-json
And like you comment, first case will output "null", the second is the correct in this case So
if ($Dependencies) { @($Dependencies) } else { @() }
is the solution
When no dependencies are found in a Win32App, I think we need to change $win32AppRelationshipsTable from:
to
Without the change I get:
I did not check, but may be we can do the same change with Remove-IntuneWin32AppDependency