/errors/teams/new-team-visibility-validateset
New-Team -Visibility: The argument does not belong to the set "Public,Private,HiddenMembership"
- 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:
New-Team -DisplayName "Project Phoenix" -Visibility PrivateReproduce it
No connection is needed; validation happens first (MicrosoftTeams 8.0.0):
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
| Value | Meaning |
|---|---|
| Private | Owners approve or add members |
| Public | Anyone in the organization can join |
| HiddenMembership | Membership 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:
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
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 message | Cause |
|---|---|
| "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 value | Not this error: matching ignores case, so the command goes on and fails only if there is no connection |
Fix and confirm
- Pick one of the three values. For an ordinary team use
PrivateorPublic;HiddenMembershipis meant for class teams in education tenants. - In scripts, trim the value and give a default for empty cells, for example
$vis = if ($_.Visibility) { $_.Visibility.Trim() } else { 'Private' }. - 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.