I hope someone can help me with this.
I'm trying to create a small powershell script that should generate a output like this:
Servername Users
Server01 10
Server02 11
Server03 9
The command:
(get-xasession -farm | Select-Object Accountname | Sort AccountName | Get- Unique -AsString).count
Gives me the total amount of unique users within the enviroment.
The (small) script:
add-pssnapin -name citrix.xenapp.* -ErrorAction SilentlyContinue
$sessions=0
$servers=@(Get-XAServer | Where-Object {$_.FolderPath -match 'Servers/2 Publishing Servers'} | Sort ServerName)
foreach ($server in $servers)
{
(Get-XASession -Servername $server | Select-Object AccountName -Unique).count
}
Gives me a unique count per server, only it is not showing which server.
So, I'm able to get the total count, the individual count but not formatted into a table.
And yes. I'm new to this. Trying (with a lot of Google) to find my way around in Powershell. Only, now I'm stuck.
Can you check this :
add-pssnapin -name citrix.xenapp.* -ErrorAction SilentlyContinue
$sessions=0
$servers=@(Get-XAServer | Where-Object {$_.FolderPath -match 'Servers/2 Publishing Servers'} | Sort ServerName | select -ExpandProperty ServerName)
$data= @()
foreach ($server in $servers) {
$data += new-object -TypeName psobject -Property @{name = $server; count = (Get-XASession -Servername $server | Select-Object AccountName -Unique).count }
}
$data