framework started
This commit is contained in:
parent
dd49390aa0
commit
80fb3c6347
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user