I've come across an issue I can't explain. When I use a variable in the below statement, I get incorrect data as my result. If instead I use the value the variable represents, then I get the expected data. The workaround is easy, but I'm curious as to what the problem is. I'd expect the string and the value the string represents to provide the same results.
I'm using Get-CSOnlineUser
and filtering by StreetAddress
. I assigned the address of Super Secret Address
to a variable $location
. When I use the variable name it returns the wrong results. When I use the value of the variable it returns the correct results
This code gives the wrong results:
#Returns a table of SFB Users filtered by location and whether or not they have enterprise voice
#Variables
$location = 'Super Secret Address'
#Get all enterprise voice users at specified address
Get-CsOnlineUser -Filter {StreetAddress -eq $location -and VoicePolicy -eq "BusinessVoice"} |ft DisplayName, Alias, Office, Phone, VoicePolicy, LineURI
#Get non-enterprise voice- users at specified address
Get-CsOnlineUser -Filter {StreetAddress -eq $location -and VoicePolicy -eq "HybridVoice"} |ft DisplayName, Alias, Office, Phone, VoicePolicy, LineURI
This gives the right results:
#Get all enterprise voice users at specified address
Get-CsOnlineUser -Filter {StreetAddress -eq 'Super Secret Address' -and VoicePolicy -eq "BusinessVoice"} |ft DisplayName, Alias, Office, Phone, VoicePolicy, LineURI
#Get non-enterprise voice- users at specified address
Get-CsOnlineUser -Filter {StreetAddress -eq 'Super Secret Address' -and VoicePolicy -eq "HybridVoice"} |ft DisplayName, Alias, Office, Phone, VoicePolicy, LineURI
Edit: Apologies. I should have clarified. The wrong results were showing a different subset of users that did not work at that StreetAddress
. Interestingly, it seems like those users were contractors. Aside from that, I'm not seeing a pattern here.
In addition to the wrong subset of users, I saw this warning repeat itself within the results
WARNING: "OriginalRegistrarPool" with identity "123456789" assigned to "sip:user@company.com" has been removed from configuration store.