The New-MgPlannerPlan cmdlet in Microsoft Graph PowerShell is a powerful tool for creating new plans in Microsoft Planner. This cmdlet allows you to automate the creation of plans (either associated with specific Microsoft 365 groups or standalone plans). In this article, we will explore the syntax, usage examples, tips, use cases, possible errors, and enhancements to help you effectively utilize this cmdlet.
New-MgPlannerPlan -BodyParameter <Object>
The -BodyParameter property is mandatory and takes a hashtable containing the plan details.
$params = @{
title = "Project Launch Plan"
container = @{
url = "https://graph.microsoft.com/v1.0/groups/ebf3b108-5234-4e22-b93d-656d7dae5874"
}
}
New-MgPlannerPlan -BodyParameter $params
Note: Use New-MgGroup cmdlet to get the required Group ID.
$params = @{
title = "Personal Development Plan"
container = @{
url = "https://graph.microsoft.com/v1.0/users/your-user-id"
}
}
New-MgPlannerPlan -BodyParameter $params
Note: Use New-MgUser cmdlet to get the required User ID. This user becomes the plan owner.
$plans = @(
@{
title = "Marketing Campaign Plan"
container = @{
url = "https://graph.microsoft.com/v1.0/groups/group-id-1"
}
}
@{
title = "Product Launch Plan"
container = @{
url = "https://graph.microsoft.com/v1.0/groups/group-id-2"
}
}
)
foreach ($plan in $plans) {
New-MgPlannerPlan -BodyParameter $plan
}
$csv = Import-Csv -Path "plans.csv"
foreach ($row in $csv) {
$params = @{
title = $row.title
container = @{
url = $row.url
}
}
New-MgPlannerPlan -BodyParameter $params
}
plans.csv example:
title,url
"Sales Strategy Plan","https://graph.microsoft.com/v1.0/groups/group-id-3"
"Customer Support Plan","https://graph.microsoft.com/v1.0/groups/group-id-4"
Cause: The account used to run the cmdlet does not have the required permissions.
Solution: Ensure the account has Group.ReadWrite.All Graph API permission.
# Example of handling insufficient permissions error
try {
New-MgPlannerPlan -BodyParameter $params
} catch {
Write-Host "Error: Insufficient Permissions. Ensure the account has the necessary permissions."
}
Cause: The URL provided in the container property is incorrect.
Solution: Verify the URL and ensure it follows the correct format with the group or user ID.
$params = @{
title = "Valid Plan"
container = @{
url = "https://graph.microsoft.com/v1.0/groups/valid-group-id"
}
}
try {
New-MgPlannerPlan -BodyParameter $params
} catch {
Write-Host "Error: Invalid Container URL. Verify the URL format and group/user ID."
}
Cause: The -BodyParameter hashtable does not include all required properties.
Solution: Ensure the title and container properties are included in the hashtable.
$params = @{
# Missing required properties
}
try {
New-MgPlannerPlan -BodyParameter $params
} catch {
Write-Host "Error: Missing Required Properties. Ensure 'title' and 'container' are included."
}
The New-MgPlannerPlan cmdlet is a versatile tool for creating plans in Microsoft Planner. Whether you need to create plans associated with specific groups or standalone plans, this cmdlet provides the flexibility to automate the process efficiently. By following the usage examples, tips, and handling possible errors effectively, you can leverage the power of this cmdlet to enhance your planning and project management capabilities within Microsoft 365.
For more detailed information, refer to the official New-MgPlannerPlan documentation.
© m365corner.com. All Rights Reserved. Design by HTML Codex