mirror of
https://github.com/Thumbscrew/PSMatrix.git
synced 2025-04-04 14:23:39 +00:00
add Get-MatrixJoinedMembers
This commit is contained in:
parent
c16d850676
commit
5cc813f849
@ -72,7 +72,8 @@ PowerShellVersion = '7.0'
|
||||
FunctionsToExport = @(
|
||||
'New-MatrixAccessToken',
|
||||
'Remove-MatrixAccessToken',
|
||||
'Get-MatrixJoinedRooms'
|
||||
'Get-MatrixJoinedRooms',
|
||||
'Get-MatrixJoinedMembers'
|
||||
)
|
||||
|
||||
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
|
||||
|
36
public/Get-MatrixJoinedMembers.ps1
Normal file
36
public/Get-MatrixJoinedMembers.ps1
Normal file
@ -0,0 +1,36 @@
|
||||
function Get-MatrixJoinedMembers {
|
||||
param(
|
||||
[Parameter(Mandatory)]
|
||||
[string]$ServerUrl,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[SecureString]$AccessToken,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[string]$RoomId
|
||||
)
|
||||
|
||||
$url = New-MatrixUrl -ServerUrl $ServerUrl -ApiPath "_matrix/client/v3/rooms/$RoomId/joined_members"
|
||||
Write-Debug "URL: $url"
|
||||
$headers = Get-MatrixAuthHeaders -AccessToken $AccessToken
|
||||
|
||||
try {
|
||||
$res = Invoke-RestMethod -Uri $url -Headers $headers
|
||||
$joinedObject = $res.joined
|
||||
$members = @()
|
||||
|
||||
$joinedObject.PSObject.Properties | ForEach-Object {
|
||||
$member = [PSCustomObject]@{
|
||||
MatrixId = $_.Name
|
||||
DisplayName = $_.Value.display_name
|
||||
AvatarUrl = $_.Value.avatar_url
|
||||
}
|
||||
|
||||
$members += $member
|
||||
}
|
||||
|
||||
return $members
|
||||
} catch {
|
||||
Write-Error $_
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user