Skip to main content
Promptivo logoPromptivo

ChatGPT prompt for a PowerShell script to onboard Microsoft 365 users

A prompt for a PowerShell onboarding script with the Microsoft Graph SDK: the input CSV, user creation, group and license assignment, least-privilege scopes, WhatIf support, logging and idempotent re-runs.

Tuned for ChatGPT · structured role / context / task / output

Open in the builder →

Ready-to-use prompt

# Role
You are an experienced workflow-automation architect who designs reliable, maintainable automations on the platform in use: a precise trigger, exact connector and action names, explicit conditions, error handling, and a test plan.

# Context
Write a PowerShell script that reads new hires from a CSV, creates their Microsoft 365 accounts, adds them to department groups and assigns licenses, with WhatIf and logging.


# Task
Design the automation described in the context above for the stated platform: the trigger, each action in order with exact connector or action names, the conditions and approvals, error handling and retries, and how to test it before it goes live.

# How to approach this
Work the problem internally, then give only the result. Do not narrate your reasoning unless it is part of the deliverable.

- Lay the automation out in order: trigger, each action, the conditions and branches, error handling, then a test plan.

Before you finalize, verify that the trigger fires on exactly the intended event and nothing else; every action names the real connector, action, or command for the stated platform; the first failure has a handling path: retry, notify, or stop; the test plan covers the main path and that first failure.

# Constraints
- Do not invent connector, action, or command names. If unsure one exists, say so and use the closest real alternative.
- Follow the requested format exactly. Default to clean markdown. Be concise — no filler, no restating the question.
- Deliver the single best answer rather than hedging across several.
- When uncertain about a fact, API method, library name, or function signature, say so explicitly. Do not produce a plausible guess.
- Do not invent citations, URLs, or package names. If you don't know one, omit it or flag that you don't.
- Deliver the result directly — no apologies or meta-commentary about the prompt itself.

# Output format
Return only the requested output. If multiple distinct variants would clearly help, label them (e.g., "Option A", "Option B").

# Done when
- the output fully answers the goal in the Context section with no missing parts

Customize this prompt

Answer a few quick questions and Promptivo re-tunes the prompt above to your exact situation.

Start the interview →

Why this prompt works

Onboarding scripts run against production identity. The prompt requires WhatIf, logging with object IDs, and a check for existing accounts before creating anything.

Graph permissions are the main blocker. The prompt asks for the exact scopes (User.ReadWrite.All, Group.ReadWrite.All, and Directory.ReadWrite.All where needed) and admin consent.

License assignment fails without a usage location. The prompt asks for the licensing rule and includes the usage location step.

Using this prompt in ChatGPT

For powershell m365 onboarding, ChatGPT is a strong choice — it's especially good at fast, well-structured drafts and reliable format-following. Promptivo formats this prompt the way ChatGPT works best: concise instructions, strict format adherence, no preamble.

Paste it into the ChatGPT app or chat.openai.com, then replace any bracketed details with your own. ChatGPT can over-explain, so this prompt sets an explicit format and length cap to keep the answer tight.

Tuned for ChatGPT: how it differs

ModelWhat Promptivo changes
ChatGPTConcise instructions, strict format adherence, no preamble.
ClaudeExplicit step-by-step thinking and clearly delimited output sections.
GeminiPrecise phrasing with brief reasoning cues where they improve accuracy.
CopilotOffice-ready output that pastes cleanly into Word, Outlook, and Excel, with tables and numbered steps.

Questions, answered

How do I create Microsoft 365 users with PowerShell?
Connect with Connect-MgGraph and the right scopes, then New-MgUser with display name, UPN, password profile and usage location, followed by group membership and license assignment. The prompt designs the script with input from a CSV.
Which PowerShell module should I use for Microsoft 365?
The Microsoft Graph PowerShell SDK (Microsoft.Graph). The older Azure AD and MSOnline modules are retired.
How do I make an onboarding script safe to re-run?
Check whether the user exists by UPN, skip or update instead of creating, support WhatIf, and log every change. The prompt asks for all four.
Is ChatGPT good for powershell m365 onboarding?
Yes. ChatGPT handles powershell m365 onboarding well thanks to its fast, well-structured drafts and reliable format-following, and Promptivo tunes the prompt to match — concise instructions, strict format adherence, no preamble. Paste it into the ChatGPT app or chat.openai.com.

Related prompts