Michael Leonard
asked on
powershell question need assistance
can someone provide a way that we can list all the members of all persistant chat rooms adding a variable to the following script:
this script works fine for one room at a time, we have over 100
this script works fine for one room at a time, we have over 100
Get-CsPersistentChatRoom -Identity <Room Name> | select-object members
ASKER
thanks oBda - what is the best way to export the results to csv?
The Export-Csv cmdlet:
Get-Content -Path C:\Temp\roomlist.txt | ForEach-Object {
$Room = $_
Get-CsPersistentChatRoom -Identity <Room Name> |
Select-Object @{n='Room'; e={$Room}}, Members
} | Export-Csv -NoTypeInformation -Path C:\Temp\rooms.csv
ASKER
hi oBda, here is what I'm seeing in the output file [no members]
Room","Members"
"room1","System.Collections.Generic.List`1[System.String]"
"room2","System.Collections.Generic.List`1[System.String]"
"room3","System.Collections.Generic.List`1[System.String]"
Sorry, can't test this, but this should expand the list:
Get-Content -Path C:\Temp\roomlist.txt | ForEach-Object {
$Room = $_
Get-CsPersistentChatRoom -Identity <Room Name> |
Select-Object @{n='Room'; e={$Room}}, @{n='Members'; e={$_.Members -join '; '}}
}
ASKER
here is what i'm seeing when running:
also we need this exported out to csv. thx
+ Get-CsPersistentChatRoom -Identity <Room Name> |
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : RedirectionNotSupported
also we need this exported out to csv. thx
My bad, copy and paste error:
Get-Content -Path C:\Temp\roomlist.txt | ForEach-Object {
$Room = $_
Get-CsPersistentChatRoom -Identity <Room Name> |
Select-Object @{n='Room'; e={$Room}}, @{n='Members'; e={$_.Members -join '; '}}
} | Export-Csv -NoTypeInformation -Path C:\Temp\rooms.csv
ASKER
still seeing this error when running:
At C:\Users\admin\Desktop\export-rooms.ps1:3 char:37
+ Get-CsPersistentChatRoom -Identity <Room Name> |
+ ~
The '<' operator is reserved for future use.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : RedirectionNotSupported
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great thanks oBDA worked perfectly
This will add the room name to the output, so that you'll be able to actually see which room has which members.
Open in new window