MSBA-229 · Lesson 7 of 12 · 22 min

PowerShell questions

▶ Video coming soon A video version of this lesson is on the way.

On the first practice assessment, Teodor lost more points to PowerShell than to any single topic. He used PowerShell every week, but mostly by copying a script from his own notes and changing one value. The exam asked him to pick the right cmdlet from four that looked alike, or to finish a command from drop-down lists. Ines gave PowerShell a whole session. “You don't need to memorize every parameter,” she said. “You need to read a cmdlet name and know what it does, and you need the handful of patterns that the exam keeps coming back to.”

This lesson covers the two modules MS-700 relies on, how to read cmdlet names, the commands that appear most often, and how to answer the question styles that use them. Every command here is a listing to read, not to run.

Two modules, two kinds of object

Teams administration in PowerShell uses two main toolsets. The Microsoft Teams PowerShell module manages Teams itself: teams and channels, and the Teams policies and voice settings, whose cmdlets begin with Cs. Microsoft Graph PowerShell manages the directory and Microsoft 365 groups that sit behind teams, along with users and licenses. The older MSOnline and AzureAD modules are retired, so any answer that uses cmdlets such as Get-MsolUser or Get-AzureADGroup is out of date.

ModuleConnect withManagesExample cmdlets
Microsoft Teams PowerShellConnect-MicrosoftTeamsTeams, channels, Teams policies, phone numbers, voice applicationsNew-Team, Get-CsOnlineUser, Grant-CsTeamsMeetingPolicy
Microsoft Graph PowerShellConnect-MgGraph with scopesGroups, users, licenses, directory objectsGet-MgGroup, Get-MgUser, Restore-MgDirectoryDeletedItem

Version details are unlikely to appear, but they help you read current documentation. Teams PowerShell version 8.0.0 became generally available in September 2026, and version 7.9.0 in July 2026 made Web Account Manager the default sign-in method for Connect-MicrosoftTeams on Windows.

Reading a cmdlet name

PowerShell cmdlets follow a verb-noun pattern. The verb says what happens; the noun says to what. In the Teams module, nouns that start with Cs belong to the Teams service configuration, a naming that dates back to Skype for Business. Policy nouns usually begin CsTeams and end with the policy kind.

VerbWhat it doesExample
GetReads settings or objectsGet-CsTeamsMeetingPolicy
NewCreates a new object, such as a policyNew-CsTeamsMeetingPolicy
SetChanges an existing objectSet-CsTeamsMeetingPolicy
GrantAssigns a policy directly to a userGrant-CsTeamsMeetingPolicy
RemoveDeletes an object or assignmentRemove-CsPhoneNumberAssignment
AddAdds a member or itemAdd-TeamUser
The cmdlet name Grant-CsTeamsMeetingPolicy split into parts: Grant, the verb that assigns; Cs, the Teams service configuration prefix; Teams, the product; MeetingPolicy, the policy kind. Below, the same pattern for New, Set and Get.
Reading a Teams policy cmdlet.

The most useful single distinction is between Set and Grant. Set changes the settings inside a policy, for every user who has it. Grant assigns a policy to a user. A question that says “make sure Dana gets the Clinical-Meetings policy” wants Grant. A question that says “turn off recording in the Clinical-Meetings policy” wants Set.

The commands that appear most often

The following listings show the patterns. Parameter names in these listings are the documented common ones; when you use them in practice, confirm current syntax with Get-Help.

Creating, populating and archiving a team with the Teams module.
# Connect to Teams
Connect-MicrosoftTeams

# Create a team, then add a channel and an owner
$team = New-Team -DisplayName "CHC-South Branch" -Visibility Private
New-TeamChannel -GroupId $team.GroupId -DisplayName "Visits Today"
Add-TeamUser -GroupId $team.GroupId -User "lead.south@corvallincare.example" -Role Owner

# Archive a team (read-only, content kept)
Set-TeamArchivedState -GroupId $team.GroupId -Archived:$true

Know that New-Team creates a team and its Microsoft 365 group in one step, that Add-TeamUser adds members and owners, and that Set-TeamArchivedState archives or unarchives. Archiving keeps content and makes the team read-only; deleting a team removes the group, and restoring it within 30 days is a directory operation, done with Graph PowerShell or the admin centers.

Restoring a deleted group with Microsoft Graph PowerShell.
# Restore a deleted Microsoft 365 group (and its team) within 30 days
Connect-MgGraph -Scopes "Group.ReadWrite.All"
Get-MgDirectoryDeletedItemAsGroup | Select-Object Id, DisplayName, DeletedDateTime
Restore-MgDirectoryDeletedItem -DirectoryObjectId "<group id>"
Changing, granting and checking meeting policies.
# Change the settings inside a policy (affects everyone who has it)
Set-CsTeamsMeetingPolicy -Identity "Clinical-Meetings" -AllowCloudRecording $false

# Assign a policy directly to one user
Grant-CsTeamsMeetingPolicy -Identity "dana.ferreira@corvallincare.example" -PolicyName "Clinical-Meetings"

# Assign a policy to a group, with a rank
New-CsGroupPolicyAssignment -GroupId "<group object id>" -PolicyType TeamsMeetingPolicy -PolicyName "Clinical-Meetings" -Rank 1

# Check which policy a user actually has, and where it came from
Get-CsUserPolicyAssignment -Identity "dana.ferreira@corvallincare.example" -PolicyType TeamsMeetingPolicy

These four lines hold most of what the exam asks about policies in PowerShell. Set edits a policy. Grant assigns it to a user. New-CsGroupPolicyAssignment assigns it to a group with a rank, which decides precedence when a user is in more than one group. Get-CsUserPolicyAssignment shows the effective policy and its source: direct or group. Lesson 8 explains precedence in full.

For large numbers of users, New-CsBatchPolicyAssignmentOperation assigns a policy to many users at once and returns an operation you can check later. It is the answer when a scenario describes thousands of users and says to minimize effort without using groups.

Phone numbers with the Teams module. The number shown is fictional.
# Assign a Calling Plan number to a user
Set-CsPhoneNumberAssignment -Identity "nadia.ross@corvallincare.example" -PhoneNumber "+19025550123" -PhoneNumberType CallingPlan

# Remove a number
Remove-CsPhoneNumberAssignment -Identity "nadia.ross@corvallincare.example" -PhoneNumber "+19025550123" -PhoneNumberType CallingPlan

# Look up a user's Teams configuration
Get-CsOnlineUser -Identity "nadia.ross@corvallincare.example"

The PhoneNumberType must match where the number comes from: CallingPlan, OperatorConnect or DirectRouting. A question that offers the right cmdlet with the wrong number type is a common trap. Get-CsOnlineUser shows a user's Teams configuration, including assigned policies and phone settings, and is often the first command in a troubleshooting question.

Other cmdlet families you may see include New-CsAutoAttendant and New-CsCallQueue for voice applications, Set-CsTenantFederationConfiguration for external access across the tenant, and the CsTeamsMessagingPolicy, CsTeamsCallingPolicy and CsTeamsEventsPolicy families, which follow the same New, Set, Grant pattern as meeting policies.

Microsoft Graph for Teams operations

The outline says “Perform operations for Teams by using PowerShell and Microsoft Graph”, and domain 2 says a team can be created with Microsoft Graph. You do not need to write Graph requests from memory, but you should know that Graph can create a team from a group, create a team from a template, list channels and manage membership, and that apps and automation use it. A question might ask which method suits an automated provisioning process that runs in a cloud service: Microsoft Graph, called by an app with the right permissions.

Answering PowerShell questions

Most PowerShell questions can be answered with three questions of your own. What is the object: a team, a policy, a number or a directory group? What is the action: read, create, change, assign or remove? And which module owns that object? Once you have those, the verb and noun follow, and only one option usually remains. Then check the one parameter that carries the scenario's detail: the rank, the number type, the archive flag or the policy name.

ScenarioObject and actionCmdlet
Turn off chat deletion for everyone with Frontline-MessagingPolicy, changeSet-CsTeamsMessagingPolicy
Give one new nurse the Frontline-Messaging policyPolicy, assign to userGrant-CsTeamsMessagingPolicy
Give every member of Branch-Care-Staff a policy, ranked firstPolicy, assign to groupNew-CsGroupPolicyAssignment
See which meeting policy a user really hasPolicy assignment, readGet-CsUserPolicyAssignment
Make an old project team read-onlyTeam, changeSet-TeamArchivedState
Bring back a team deleted last weekDirectory group, restoreRestore-MgDirectoryDeletedItem

Worked problem

Completing a command

A question shows: “[A] -Identity "sam.ortiz@corvallincare.example" -PhoneNumber "+19025550188" -PhoneNumberType [B]”. Sam's number comes from the organization's Operator Connect carrier. Choose A from Set-CsPhoneNumberAssignment, Grant-CsTeamsCallingPolicy, New-CsOnlineUser and Set-CsUser, and B from CallingPlan, OperatorConnect, DirectRouting and ServiceNumber.

Show solution
  1. Object: a phone number for a user. Action: assign.
  2. The cmdlet that assigns numbers is Set-CsPhoneNumberAssignment; Grant-CsTeamsCallingPolicy assigns a policy, and the others are distractors.
  3. The number comes from Operator Connect, so the type is OperatorConnect.

Answer: A is Set-CsPhoneNumberAssignment and B is OperatorConnect.

Getting ready to run commands

Some questions test the steps before any Teams cmdlet runs: installing the module, connecting and having the right role. These are easy points if you know the order.

StepTeams moduleMicrosoft Graph PowerShell
InstallInstall-Module MicrosoftTeamsInstall-Module Microsoft.Graph
ConnectConnect-MicrosoftTeamsConnect-MgGraph with the scopes the task needs
PermissionAn admin role such as Teams AdministratorConsent to scopes such as Group.ReadWrite.All, plus a suitable role
DisconnectDisconnect-MicrosoftTeamsDisconnect-MgGraph

A common distractor offers a command from a retired module, such as Connect-MsolService or Connect-AzureAD. Both the MSOnline and AzureAD modules are retired. If a scenario needs user or group management outside Teams, the current answer is Microsoft Graph PowerShell. Another distractor offers Connect-MgGraph with no scopes for a task that writes data; Graph needs the scope for what you intend to do.

Parameters that trip people up

Teams cmdlets are consistent, but a few parameters behave differently from what their names suggest.

ParameterWhere it appearsWhat to remember
-IdentityPolicy cmdletsOn Set, New and Get it names the policy; on Grant it names the user
-PolicyNameGrant cmdletsThe policy to assign; a null value removes the direct assignment
-GroupIdTeam cmdletsThe object ID of the team's Microsoft 365 group, not its display name
-RankGroup policy assignmentLower number means higher priority; 1 is highest
-GlobalGrant cmdletsAssigns a policy as the org-wide default instead of to one user
-GroupGrant cmdletsAn alternative way to assign to a group, with a rank

The -Identity difference catches many candidates. In Set-CsTeamsMessagingPolicy, -Identity is the name of the policy whose settings you change. In Grant-CsTeamsMessagingPolicy, -Identity is the user who receives it, and -PolicyName names the policy. A question that shows a Grant command with a policy name after -Identity is showing you a broken command.

Reading a short script

Some questions show a few lines and ask what they do, or which line must be changed. Read the script from the top, saying out loud what each line produces and what the next line uses from it.

Listing ownerless teams.
# Find teams with no owners and list them
Connect-MicrosoftTeams
$teams = Get-Team
foreach ($t in $teams) {
    $owners = Get-TeamUser -GroupId $t.GroupId -Role Owner
    if (-not $owners) { $t.DisplayName }
}

The first command connects. The second gets every team. The loop asks each team for its owners and prints the display name of any team that has none. A question might ask which cmdlet returns the owners (Get-TeamUser with the Owner role) or what the output contains (team names only). It might also offer a broken version that passes the display name to -GroupId, which would fail because the parameter expects the group's object ID.

Granting a policy from a list of users.
# Assign a messaging policy to everyone in a CSV file
$users = Import-Csv ".\branch-leads.csv"
foreach ($u in $users) {
    Grant-CsTeamsMessagingPolicy -Identity $u.UserPrincipalName -PolicyName "Branch-Leads-Messaging"
}

This works for a few dozen users. For thousands, the exam prefers a group policy assignment or New-CsBatchPolicyAssignmentOperation, because a loop of individual Grant commands is slow and creates direct assignments that later override group assignments. Lesson 8 shows why that matters.

Spotting invented cmdlets

Distractors sometimes use cmdlet names that do not exist but look plausible. Teodor learned to check three things: the verb is an approved PowerShell verb (Get, Set, New, Remove, Grant, Add); the noun prefix fits the module (Cs for Teams configuration, Team for teams, Mg for Graph); and the noun matches a real policy type. A name such as Assign-CsTeamsMeetingPolicy fails the first test, because Assign is not the verb Teams uses for policies. A name such as Set-TeamMeetingPolicy fails the second and third, because meeting policies use the Cs prefix and the plural Teams.

Looks plausibleReal cmdlet
Assign-CsTeamsMeetingPolicyGrant-CsTeamsMeetingPolicy
Set-TeamMeetingPolicySet-CsTeamsMeetingPolicy
Restore-TeamRestore-MgDirectoryDeletedItem
Get-CsUserPolicyGet-CsUserPolicyAssignment
New-TeamsChannelNew-TeamChannel

Worked problem

Fixing a broken command

An administrator runs Grant-CsTeamsMeetingPolicy -Identity "Clinical-Meetings" -PolicyName "dana.ferreira@corvallincare.example" and gets an error. What is wrong?

Show solution
  1. Identify the verb: Grant assigns a policy to a user.
  2. For Grant, -Identity takes the user and -PolicyName takes the policy.
  3. The values are swapped.

Answer: Swap the values: -Identity should be the user's sign-in name and -PolicyName should be Clinical-Meetings.

Practicing with output

The exam sometimes shows the output of a Get command instead of the command itself, and asks what it tells you. Teodor practiced by running Get-CsUserPolicyAssignment and Get-CsOnlineUser against his test users after every lab and reading the results line by line. The output of Get-CsUserPolicyAssignment lists the policy type, the policy name and a source: Direct or Group, with the group's ID and rank for a group assignment. If a question shows a user with a Group source and asks why a newly granted policy is not in effect, the likely answer is that the grant failed or has not yet applied, because a direct assignment would show as Direct.

Get-Team and Get-TeamUser output is simpler: display names, group IDs, visibility and archived state for teams; names and roles for members. A question that asks how to find the group ID needed by another cmdlet expects Get-Team filtered by display name. Teodor kept a page of real output from his test tenant, with fictional names, and used it as a reading exercise on the bus alongside his flash cards. Reading output is a skill of its own, and it improves only with practice on real results.

Felix added a last piece of advice: when two PowerShell options both look right, compare their nouns before their verbs. The verb tells you what is done; the noun tells you to what. Most PowerShell distractors use the right verb with the wrong object, such as Set on a policy when the scenario needs Grant to a user.

Common mistakes

  • MistakeUsing Set when the scenario asks to give a user a policy.

    InsteadGrant assigns a policy to a user; Set changes the policy itself.

  • MistakeChoosing MSOnline or AzureAD cmdlets.

    InsteadThose modules are retired; use Microsoft Graph PowerShell.

  • MistakePicking the right cmdlet with the wrong PhoneNumberType.

    InsteadMatch the number type to the PSTN option the number comes from.

  • MistakeRestoring a deleted team with a Teams cmdlet.

    InsteadA deleted team is a deleted Microsoft 365 group; restore it as a directory object.

  • MistakeAssigning a policy to thousands of users one Grant at a time.

    InsteadUse a group assignment or a batch assignment.

Summary and key terms

  • The Teams module manages teams, channels, policies and numbers; Graph PowerShell manages groups, users and directory objects.
  • MSOnline and AzureAD cmdlets are retired and are wrong answers in current questions.
  • Set changes a policy; Grant assigns it to a user; New-CsGroupPolicyAssignment assigns it to a group with a rank.
  • Get-CsUserPolicyAssignment shows the effective policy and whether it came from a direct or group assignment.
  • Set-CsPhoneNumberAssignment assigns numbers, with a PhoneNumberType that matches the PSTN option.
  • Answer by naming the object, the action and the module before reading the options.
Cmdlet
A PowerShell command with a verb-noun name, such as Grant-CsTeamsMeetingPolicy.
Grant
The verb Teams cmdlets use to assign a policy directly to a user.
Group policy assignment
Assigning a Teams policy to a group, with a rank that sets precedence.
Batch policy assignment
Assigning a policy to many users in one operation.
PhoneNumberType
The parameter that says whether a number comes from Calling Plans, Operator Connect or Direct Routing.
Microsoft Graph PowerShell
The current PowerShell module for Microsoft Entra ID and Microsoft 365 directory objects.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Which verb assigns a Teams policy to one user?

    Show answer

    Grant.

  2. Which cmdlet shows where a user's policy came from?

    Show answer

    Get-CsUserPolicyAssignment.

  3. Which module restores a deleted Microsoft 365 group?

    Show answer

    Microsoft Graph PowerShell, with Restore-MgDirectoryDeletedItem.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz