Agent 365 Migration Script Repository
A repository for automating the transition to Agent 365 using PowerShell and Microsoft Graph.
### FILE: index.php
<?php
session_start();
// Ensure access token is set
if (!isset($_SESSION['ms_access_token'])) {
echo 'Access token not found';
exit;
}
$accessToken = $_SESSION['ms_access_token'];
$endpoint = '/v1.0/agent365/YOUR_AGENT_ID';
try {
// Fetch data from Microsoft Graph
$response = $ms->graphCall($endpoint, $accessToken);
$agentData = json_decode($response, true);
// Check if data retrieval was successful
if (!$agentData) {
throw new Exception('Failed to retrieve agent data.');
}
// Render a premium card with the agent details
render_premium_card(
'Agent 365 Data',
json_encode($agentData),
null,
'up',
'📊',
null
);
} catch (Exception $e) {
// Handle errors
echo 'Error: ' . $e->getMessage();
}
?>
### FILE: scripts/Automation.ps1
<#
.SYNOPSIS
Retrieves data from Agent 365 using Microsoft Graph API.
.DESCRIPTION
This script connects to the Microsoft Graph API and retrieves specific agent data using the new Agent 365 endpoints.
.EXAMPLE
./Automation.ps1
#>
try {
# Connect to Microsoft Graph
Connect-MgGraph -Scopes "https://graph.microsoft.com/.default"
# Specify agent identifier
$agentId = "YOUR_AGENT_ID"
# API call to fetch the agent data
$response = Invoke-RestMethod -Uri "https://graph.microsoft.com/v1.0/agent365/$agentId" -Headers @{Authorization = "Bearer $($token)"} -Method GET
# Output the retrieved data
Write-Host $response
} catch {
# Error handling
Write-Error "An error occurred: $_"
}
<#
.NOTES
Author: Souhaiel Morhag
Company: MSEndpoint.com
Blog: https://msendpoint.com
Academy: https://app.msendpoint.com/academy
LinkedIn: https://linkedin.com/in/souhaiel-morhag
GitHub: https://github.com/Msendpoint
License: MIT
#>
⚠️ Always review and validate PowerShell scripts in a non-production pilot group before tenant-wide deployment.