From 80fb3c6347f0f3c68a5c4452a3447501e2ed6fc0 Mon Sep 17 00:00:00 2001 From: Erik Date: Tue, 3 Sep 2024 14:54:45 -0600 Subject: [PATCH] framework started --- Ajera-ListProjects.ps1 | 51 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/Ajera-ListProjects.ps1 b/Ajera-ListProjects.ps1 index 0f5e285..2070fbc 100644 --- a/Ajera-ListProjects.ps1 +++ b/Ajera-ListProjects.ps1 @@ -8,18 +8,21 @@ $Headers = @{ 'Content-Type' = 'application/json' Accept = 'application/json' } + +$Project_Out = @() + function Connect-Ajera { $Session_Body = @{ Method = "CreateAPISession" Username = "MMIntegration" Password = "@s0Nny2day" - APIVersion = 2 + APIVersion = 1 UseSessionCookie = $false } | ConvertTo-Json - $Session_token = Invoke-WebRequest -Uri $MPE_Ajera_URI -Method Post -Body $Session_Body -Headers $Headers -SkipCertificateCheck + $Session_token = Invoke-WebRequest -Uri $MPE_Ajera_URI -Method Post -Body $Session_Body -Headers $Headers return $Session_token } @@ -34,7 +37,8 @@ function Disconnect-Ajera { } | ConvertTo-Json - Invoke-WebRequest $MPE_Ajera_URI -Headers $Headers -Body $Session_Body -SkipCertificateCheck + $resp = Invoke-WebRequest $MPE_Ajera_URI -Headers $Headers -Body $Session_Body + return $null } @@ -56,5 +60,44 @@ $req_body = @{ } | ConvertTo-Json -$resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post -SkipCertificateCheck +$resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post +$projects = ($resp.Content | convertfrom-json).Content.projects + +foreach ($project in $projects) { + # Get Client name for each project. + $req_body = @{ + Method = 'GetProjects' + SessionToken = $APIKey + MethodArguments = @{ + RequestedProjects = @($project.ProjectKey) + } + } | ConvertTo-Json + + $resp = Invoke-WebRequest -Uri $MPE_Ajera_URI -Headers $Headers -Body $req_body -Method Post + $project_info = ($resp.Content | ConvertFrom-Json).Content + $Project_SharePoint_FolderName = $project.ID + "-" + $project_info.Projects.InvoiceGroups.Client.Description + '-' + $project.Description + + $Project_Out += [PSCustomObject]@{ + + ProjectNumber = $project.ID + ProjectClient = $project_info.Projects.InvoiceGroups.Client.Description + ProjectName = $project.Description + Project_Ajera_LastUpdate = $project_info.Projects.LastModifiedDate + Project_SharePoint_TimeStamp = $null + Project_SharePoint_FolderName = $Project_SharePoint_FolderName + } + +} +## Disconnect from Ajera. +$APIKey = Disconnect-Ajera -Token_to_Kill $APIKey + +$Project_Out | out-gridview + +# Now, we connect to sharepoint online and add folders + +# Set the library URL and subfolder name +$libraryUrl = "https://mpeeng.sharepoint.com/sites/MPEProjectEmails/Shared Documents" +$subfolderName = "New Subfolder" + +# Create the subfolder