add `Join-MatrixRoom` function

This commit is contained in:
James 2022-03-31 21:30:43 +01:00
parent c16d850676
commit 35edf29957
2 changed files with 25 additions and 1 deletions

View File

@ -72,7 +72,8 @@ PowerShellVersion = '7.0'
FunctionsToExport = @( FunctionsToExport = @(
'New-MatrixAccessToken', 'New-MatrixAccessToken',
'Remove-MatrixAccessToken', 'Remove-MatrixAccessToken',
'Get-MatrixJoinedRooms' 'Get-MatrixJoinedRooms',
'Join-MatrixRoom'
) )
# 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. # 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.

View File

@ -0,0 +1,23 @@
function Join-MatrixRoom {
param(
[Parameter(Mandatory)]
[string]$ServerUrl,
[Parameter(Mandatory)]
[SecureString]$AccessToken,
[Parameter(Mandatory)]
[string]$RoomAliasOrId
)
$url = New-MatrixUrl -ServerUrl $ServerUrl -ApiPath "_matrix/client/v3/join/$RoomAliasOrId?server_name=techlore.net"
$headers = Get-MatrixAuthHeaders -AccessToken $AccessToken
$method = "POST"
try {
$res = Invoke-RestMethod -Uri $url -Headers $headers -Method $method
return $res
} catch {
Write-Error $_
}
}