I am using below PowerShell code in azure functions to retrieve rows of users in azure table who belongs to a particular location.
$Rows = Get-AzTableRow -table $cloudTable -customFilter "((Location eq '$loc') and (PartitionKey eq 'User'))"
Next, I need to pass the result ($Rows
) of the above query to a function as parameter. Tried to define the function as
function display_rows($param){
$tempcount = $param.Count
for($i=0; $i -lt $tempcount; $i ){
...code body...
}
}
and invoke the function as display_rows "$Rows"
. But it seems it's not working as intended. Is this the proper way to pass the result of Get-AzTableRow
to a function? please help me with this.
CodePudding user response:
the basic problem is that you are sending a "stringified" version of the object to the function. [grin]
when you do ...
display_rows "$Rows"
... are not sending the object in $Rows
to the function. you are converting that object into a string and sending that.
that simple string object aint what you want. [grin] you want the complex object instead.
so, the fix is to NOT wrap $Rows
in double quotes. just use it bare, like so ...
display_rows $Rows
that will send the object contained in the $Var to the function, not the .ToString()
of that object.
as an aside, you otta NEVER use quotes around a $Var unless you are sure you need them.