diff --git a/PSMatrix.psd1 b/PSMatrix.psd1 index 68b668a..6d742a0 100644 --- a/PSMatrix.psd1 +++ b/PSMatrix.psd1 @@ -72,7 +72,8 @@ PowerShellVersion = '7.0' FunctionsToExport = @( 'New-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. diff --git a/public/Join-MatrixRoom.ps1 b/public/Join-MatrixRoom.ps1 new file mode 100644 index 0000000..807b8f1 --- /dev/null +++ b/public/Join-MatrixRoom.ps1 @@ -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 $_ + } +} \ No newline at end of file