Functions/Get-WorkSpaceReport.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$Report=@()
foreach($w in Get-WKSWorkspace) {
    $ConnectionStatus = Get-WKSWorkspacesConnectionStatus -WorkspaceId $w.WorkspaceId
    $Tags = ""
    foreach ($t in (Get-WKSTag -WorkspaceId $w.WorkspaceId)) {
        $Tags = $Tags+"$($t.Key):$($t.Value),"
    }
    If ($Tags -ne "") {$Tags = $Tags.Substring(0,$tags.Length-1) }
    $Report += New-Object PSObject -Property @{            
        WorkSpaceId     = $w.WorkspaceId
        UserName        = $w.UserName
        LastLoginTime   = $ConnectionStatus.LastKnownUserConnectionTimestamp
        ConnectionState = $ConnectionStatus.ConnectionState
        Tags            = $Tags
    } 
}
$Report | Export-Csv 'C:\Report.csv' -NoTypeInformation