Jump to content
Updated Privacy Statement
  • 0

How do I get Braces output in csv using Powershell for Get-BrokerEntitlementPolicyRule . It works fine with Get-BrokerApplication


Sanchit Gupta1709161590

Question

If I run 

Get-BrokerApplicationGroup * | Select Description, Enabled, Name, @{N='Accounts';e={[System.String]::Join(", ",$_.AssociatedUserNames)}}

 

I get application name and Account who has access on it in a column 'Account' and value as Domain\ABC, Domain\XYZ in csv file

 

but I run the 

 

Get-BrokerEntitlementPolicyRule * | select  PublishedName, IncludedUsers, @{N='Accounts';e={[System.String]::Join(", ",$_.IncludedUsers)}}

 

I get 'Citrix.Broker.Admin.SDK.User' written in output as well as in .csv file - screenshot attached as Incorrect output

 

but If i do not use expression and run below 

 

Get-BrokerEntitlementPolicyRule * | select  PublishedName, IncludedUsers, IncludedUsers

 

Then i get proper name like Domani\ABC, Domain\XYZ in powershell output (screenshot attached as correct output) but i export it in .CSV file it comes out to be written as 'Citrix.Broker.Admin.SDK.User' instead of Domain\ABC.

 

How do i get the proper output in .csv with username as Domain\ABC ?

 

Correct output.JPG

incorrect output.JPG

Link to comment

2 answers to this question

Recommended Posts

  • 0

Hey !

 

Firstly, I was shocked to see there were no answers yet. 

 

I needed the same kind of output i.e., in csv and figured it out. Below shows what I explored while breaking it down. 

Ref: Attachement

 

I took the output of brokerentitlementrulepolicy to a variable and looped in "foreach".

Checked the type first and then the properties of it later as shown in image.

 

The reason you are getting error is because:

Quote

The IncludedUsers is not a string but an Array, which contains properties FullName, HomezoneName, HomeZoneUid, Name, SID, UPN

 

  • When you try to export in csv, since is not in the proper type, it shows 'Citrix.Broker.Admin.SDK.User'.
  • When you try to display on the screen without exporting, it displays the usernames seperated by comma in '{' ,  '}'

To  get the IncludedUsers in the form 'DOMAIN\User' select the sub property Name from it.

 

Here's complete script for you on how you do it:

asnp citrix*
$desklist = @()
$deskreport = ".\deskreport.csv"

$Desktops = Get-BrokerEntitlementPolicyRule

foreach($desk in $desktops){

#$desk.gettype()
#$desk.IncludedUsers|gm

 $Properties = @{
				PublishedName =	$desk.PublishedName            
				IncludedUsers =	($desk.IncludedUsers.Name  -join ";").ToString()

                }
                
 $deskList += New-Object psobject -Property $properties|
 Select Name,PublishedName
}

 #$desklist
 $desklist|Export-Csv -NTI $deskreport

 

 

Cheers !

:12_slight_smile:

 

here.jpg

Link to comment
  • 0
On 10/15/2020 at 3:39 AM, Rahul Vemuganti said:

Hey !

 

Firstly, I was shocked to see there were no answers yet. 

 

I needed the same kind of output i.e., in csv and figured it out. Below shows what I explored while breaking it down. 

Ref: Attachement

 

I took the output of brokerentitlementrulepolicy to a variable and looped in "foreach".

Checked the type first and then the properties of it later as shown in image.

 

The reason you are getting error is because:

 

  • When you try to export in csv, since is not in the proper type, it shows 'Citrix.Broker.Admin.SDK.User'.
  • When you try to display on the screen without exporting, it displays the usernames seperated by comma in '{' ,  '}'

To  get the IncludedUsers in the form 'DOMAIN\User' select the sub property Name from it.

 

Here's complete script for you on how you do it:


asnp citrix*
$desklist = @()
$deskreport = ".\deskreport.csv"

$Desktops = Get-BrokerEntitlementPolicyRule

foreach($desk in $desktops){

#$desk.gettype()
#$desk.IncludedUsers|gm

 $Properties = @{
				PublishedName =	$desk.PublishedName            
				IncludedUsers =	($desk.IncludedUsers.Name  -join ";").ToString()

                }
                
 $deskList += New-Object psobject -Property $properties|
 Select Name,PublishedName
}

 #$desklist
 $desklist|Export-Csv -NTI $deskreport

 

 

Cheers !

:12_slight_smile:

 

here.jpg

 

On 10/15/2020 at 3:39 AM, Rahul Vemuganti said:

Hey !

 

Firstly, I was shocked to see there were no answers yet. 

 

I needed the same kind of output i.e., in csv and figured it out. Below shows what I explored while breaking it down. 

Ref: Attachement

 

I took the output of brokerentitlementrulepolicy to a variable and looped in "foreach".

Checked the type first and then the properties of it later as shown in image.

 

The reason you are getting error is because:

 

  • When you try to export in csv, since is not in the proper type, it shows 'Citrix.Broker.Admin.SDK.User'.
  • When you try to display on the screen without exporting, it displays the usernames seperated by comma in '{' ,  '}'

To  get the IncludedUsers in the form 'DOMAIN\User' select the sub property Name from it.

 

Here's complete script for you on how you do it:


asnp citrix*
$desklist = @()
$deskreport = ".\deskreport.csv"

$Desktops = Get-BrokerEntitlementPolicyRule

foreach($desk in $desktops){

#$desk.gettype()
#$desk.IncludedUsers|gm

 $Properties = @{
				PublishedName =	$desk.PublishedName            
				IncludedUsers =	($desk.IncludedUsers.Name  -join ";").ToString()

                }
                
 $deskList += New-Object psobject -Property $properties|
 Select Name,PublishedName
}

 #$desklist
 $desklist|Export-Csv -NTI $deskreport

 

 

Cheers !

:12_slight_smile:

 

here.jpg

So cool!  I think the case point is The IncludedUsers is not a string but an Array, which contains properties FullName, HomezoneName, HomeZoneUid, Name, SID, UPN

 

Thanks !

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...