Skip to content

/errors/teams/new-team-visibility-validateset

New-Team -Visibility: The argument does not belong to the set "Public,Private,HiddenMembership"

verified onenvironmentlocal · windows 10.0.26200 arm64 · GNU bash 5.3.15 (Git Bash)updated
tool
Microsoft Teams PowerShell
exit code
1
versions
MicrosoftTeams 8.0.0, Windows PowerShell 5.1
os
windows, linux, macos

Cannot validate argument on parameter 'Visibility'. The argument "Org" does not belong to the set "Public,Private,HiddenMembership" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again. means New-Team -Visibility got a value outside its allowed list. PowerShell checks it before the cmdlet runs, so the error appears even without a Teams connection. Use one of the three values:

powershell
New-Team -DisplayName "Project Phoenix" -Visibility Private

Reproduce it

No connection is needed; validation happens first (MicrosoftTeams 8.0.0):

powershell
Import-Module MicrosoftTeams
try {
  New-Team -DisplayName "Project Phoenix" -Visibility Org -ErrorAction Stop
} catch {
  $_.Exception.Message
  $_.FullyQualifiedErrorId
}

Output

Cannot validate argument on parameter 'Visibility'. The argument "Org" does not belong to the set "Public,Private,HiddenMembership" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
ParameterArgumentValidationError,Microsoft.Teams.PowerShell.TeamsCmdlets.NewTeam

The three values

ValueMeaning
PrivateOwners approve or add members
PublicAnyone in the organization can join
HiddenMembershipMembership is hidden from non-members (education class teams)

The same kind of message appears for -Template (allowed: EDU_Class, EDU_PLC) and for Add-TeamUser -Role (allowed: Owner, Member). In PowerShell you can press Tab after -Visibility to cycle through the valid values.

Bulk creation from CSV

A blank or padded cell gives the same error with an empty or odd-looking argument. Clean the value first:

powershell
Import-Csv .\teams.csv | ForEach-Object {
  New-Team -DisplayName $_.Name -Visibility $_.Visibility.Trim()
}

What the message means

ValidateSet is a PowerShell attribute that lists the only strings a parameter accepts. PowerShell checks it while binding parameters, before the cmdlet body runs, so the request never reaches Microsoft Teams and no connection is needed to see the error. The part in quotes after "The argument" is exactly what the cmdlet received, which makes the cause easy to spot.

How to recognise each cause

powershell
Import-Module MicrosoftTeams
foreach ($v in '', ' Private', 'private') {
  try { New-Team -DisplayName "Project Phoenix" -Visibility $v -ErrorAction Stop }
  catch { "[$v] " + $_.Exception.Message }
}

Output

[] Cannot validate argument on parameter 'Visibility'. The argument "" does not belong to the set "Public,Private,HiddenMembership" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
[ Private] Cannot validate argument on parameter 'Visibility'. The argument " Private" does not belong to the set "Public,Private,HiddenMembership" specified by the ValidateSet attribute. Supply an argument that is in the set and then try the command again.
[private] You must call the Connect-MicrosoftTeams cmdlet before calling any other cmdlets.
Argument in the messageCause
"Org", "Internal", "Hidden"A value from the Teams admin center or another product, not a New-Team value
""An empty CSV cell or an unset variable
" Private" or "Private "Spaces around the value, usually from a CSV export
A lowercase valid valueNot this error: matching ignores case, so the command goes on and fails only if there is no connection

Fix and confirm

  1. Pick one of the three values. For an ordinary team use Private or Public; HiddenMembership is meant for class teams in education tenants.
  2. In scripts, trim the value and give a default for empty cells, for example $vis = if ($_.Visibility) { $_.Visibility.Trim() } else { 'Private' }.
  3. Run the command again. If the validation passes, the next message is either the new team object or a connection error such as You must call the Connect-MicrosoftTeams cmdlet, which means the value was accepted.

Set-Team behaves differently

In MicrosoftTeams 8.0.0, Set-Team -Visibility and Get-Team -Visibility have no validation set, so a wrong value is not caught locally: Get-Team simply returns nothing, and Set-Team sends the value to the service. Check the value yourself before calling them. The full parameter list is on Get-Team and New-Team.

FAQ

Is the value case-sensitive?

No. private and PRIVATE pass validation; only the spelling matters. With a valid value and no connection, the next error you see is the not-connected message.

Can I change an existing team to HiddenMembership?

The Set-Team help lists only Private and Public as valid values for -Visibility, so choose HiddenMembership when you create the team with New-Team. If you omit -Visibility, New-Team creates a Private team.

Why does the same CSV work for some rows and fail for others?

The failing rows have an empty cell or extra spaces around the value. The quoted argument in the message shows exactly what was passed, including spaces.

Sources