AjeratoMailManager/Ajera-ListProjects.ps1

61 lines
1.5 KiB
PowerShell
Raw Normal View History

2024-03-08 10:38:23 -07:00
<#
https://help.deltek.com/Product/Ajera/api/projects.html#messages-api-endpoint-post
#>
2024-04-09 16:30:03 -06:00
$MPE_Ajera_URI = "https://ajera.mpe.ca/ajera/AjeraAPI.ashx?ew0KICAiRGF0YWJhc2VOYW1lIjogIkFqZXJhIg0KfQ%3d%3d"
$Headers = @{
'Content-Type' = 'application/json'
Accept = 'application/json'
}
function Connect-Ajera {
2024-03-08 10:38:23 -07:00
$Session_Body = @{
Method = "CreateAPISession"
Username = "MMIntegration"
2024-04-09 16:30:03 -06:00
Password = "@s0Nny2day"
APIVersion = 2
UseSessionCookie = $false
} | ConvertTo-Json
2024-03-08 10:38:23 -07:00
2024-04-09 16:30:03 -06:00
$Session_token = Invoke-WebRequest -Uri $MPE_Ajera_URI -Method Post -Body $Session_Body -Headers $Headers -SkipCertificateCheck
return $Session_token
}
function Disconnect-Ajera {
param (
$Token_to_Kill
)
$Session_Body = @{
Method = "EndAPISession"
SessionToken = $Token_to_Kill
} | ConvertTo-Json
Invoke-WebRequest $MPE_Ajera_URI -Headers $Headers -Body $Session_Body -SkipCertificateCheck
}
if (!($APIKey)) {
# get session api key if not already loaded
$Session = Connect-Ajera
2024-04-09 16:30:03 -06:00
$resp = $Session.Content | ConvertFrom-Json
$APIKey = $resp.Content.SessionToken
}
2024-03-08 10:38:23 -07:00
$req_body = @{
2024-04-09 16:30:03 -06:00
Method = 'ListProjects'
SessionToken = $APIKey
2024-03-08 10:38:23 -07:00
MethodArguments = @{
2024-04-09 16:30:03 -06:00
FilterByStatus = @("Active")
2024-03-08 10:38:23 -07:00
}
} | ConvertTo-Json
2024-04-09 16:30:03 -06:00
$resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck