Quantcast
Channel: Active questions tagged return-value - Stack Overflow
Viewing all articles
Browse latest Browse all 210

Powershell function return pscustomobject out-gridview show incorrectly results

$
0
0

This function:

    function Get-UserNameSIDfromAD {        param(            [string] $LoginName        )        [string] $domain        [string] $username        $domain, $username = $LoginName.split('\')        $w32usracc = Get-CimInstance -ClassName win32_useraccount -Filter "Name='$username' and Domain='$domain'" | Select-Object -Property SID        $res = [pscustomobject] @{            ID      = 1            SqlSID  = $w32usracc.SID            Message = 'OK'        }        return $res    }    #Using the function and get the result in variable and show using out-gridview    $val = Get-UserNameSIDfromAD -LoginName 'mydomain\user1'    $val | out-gridview 

image of the output in powershell

Grid shows incorrectly the information, if run the code without function, the grid shows information correctly.

Please any advice, thank in advance.


Viewing all articles
Browse latest Browse all 210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>