Forum Discussion
Sebastian cerazy
Nov 18, 2020Brass Contributor
Get-Team -DisplayName via variable with spaces
See below, I cannot find what makes it behave this way: Get-Team -DisplayName "`"$teamName`"" return nothing! PS C:\PSScripts> $teamName= "xx Year Group"
PS C:\PSScripts> Write-Host "`"...
VasilMichev
Nov 18, 2020MVP
First of all, you shouldnt be using identifiers such as DisplayName, as you can easily have multiple objects returned in a large tenant (duplicate values). Best use unique identifier such as the ExternalObjectId.
In any case, you can do it like this:
$name = "Project Tango"
Get-Team -DisplayName $name
GroupId DisplayName
------- -----------
7503c511-dd24-45bf-8b43-6a280b815121 Project Tango
no need to escape the variable or anything
- SebCerazyNov 18, 2020Iron Contributor
Just realized that get-team is CaSe SeNsItIvE !