Display Question with New-UDCard

Hello,
I am having some problems with New-UDCard, could be I am using the wrong settings as I a relatively new to UD.

I have these commands:
$User = Get-ADUser -Identity $Text -Properties *

New-UDRow -Columns {
   New-UDColumn -Size 6 -Content {
        New-UDCard -Title "Group Membership" -Content{ 
            (Get-ADPrincipalGroupMembership $User | select name).Name
        }

In Powershell they are listed one per line, but when I try and add them to the New-UDCard they are placed in a contiguous line. As I said I am new to this and haven’t got my head around all of the commands.

If anyone could help I would really appreciate it.

Kind Regards,

Sean Buckle

Hi Sean,

Take a look at New-UDCollection and New-UDCollectionItem.

New-UDRow -Columns {

   New-UDColumn -Size 6 -Content {
   
		New-UDCard -Title "Group Membership" -Content { 
			
			New-UDCollection -Content {
			
				$names = (Get-ADPrincipalGroupMembership $User | select name).Name
				foreach($name in $names){
				
					New-UDCollectionItem -Content { 
						$name
					}
				}
			}
		}
	}
}

Replace your UDCard with this :

New-UDCard -Title "Group Membership" -Text "$((Get-ADPrincipalGroupMembership $User | select name).Name | Out-String)"

The -Text parameter combined with a subexpression and Out-String does the trick for these kind of situation.

edit:

Oh, by the way, you don’t need to do Select Name then getting that property. You can use the -ExpandProperty parameter of the Select-Object cmdlet.

New-UDCard -Title "Group Membership" -Text "$(Get-ADPrincipalGroupMembership $User | select -ExpandProperty name | Out-String)"