Public/Authentication/Get-JCOrganization.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Function Get-JCOrganization
{
    [CmdletBinding()]
    param ()
    Begin
    {
        Connect-JCOnline -force | Out-Null
        $resultsArrayList = New-Object System.Collections.ArrayList
    }
    Process
    {
        $RawResults = Get-JCObject -Type:('organization') -Fields:('_id', 'displayName')
        ForEach ($org In $RawResults)
        {
            $MSPOrg = [PSCustomObject]@{
                'OrgID'       = $org._id
                'displayName' = $org.displayName
            }
            $resultsArrayList.add($MSPOrg) | Out-Null
        }
    }
    End
    {
        Return $resultsArrayList
    }
}