Find Microsoft Teams Emergency Addresses using PowerShell
5K views
Jan 16, 2024
Need to view all your Microsoft Teams voice user emergency addresses? Enter PowerShell! Use the PowerShell script in this video to export all your users' emergency addresses. Find Microsoft Teams Emergency Address using PowerShell https://jeffbrown.tech/microsoft-teams-emergency-address-powershell/ Full Script Code https://gist.github.com/JeffBrownTech/9e2c34d507115357bfeac9a4fe3ef6f4#file-get-teamsvoiceuserinfo-ps1 00:00 Introduction 00:21 Emergency Addresses Overview 04:09 PowerShell Script 10:20 Summary
View Video Transcript
0:00
Hey everyone, let's go ahead and continue talking about Microsoft Teams PowerShell and how you can
0:05
use PowerShell to give you more information than what you can find inside the Teams Admin Center
0:10
Again, this is just to demonstrate how you can use PowerShell to find information or to do tasks
0:15
that aren't always available inside the Teams Admin Center. Let's go ahead and get started
0:20
What we'll cover today is how you can build a report of all the Teams emergency addresses
0:25
associated with your users and phone numbers. This information is available inside the Teams
0:30
Admin Center, but it's really not in a great place or altogether where you can easily look through it
0:36
To demonstrate that, let's go ahead and jump out to the Teams Admin Center and get started
0:40
talking a little bit about emergency addresses, where you can find them in the Admin Center
0:44
and then we'll switch over to PowerShell and a script that I've written to show all your
0:50
users' emergency addresses. Let's get started by taking a look at emergency addresses. Let's go
0:56
under Locations and Emergency Addresses, and here you can see I currently have one emergency address
1:03
for my headquarters office. Let's go ahead and select into that. So it has a primary address
1:10
here in the United States. Within emergency addresses, you can also have places which are
1:15
more specific areas or locations inside the main emergency address. So you can see here I have one
1:22
place referencing suite 104, number 912. I could have multiple places in here, and each one of
1:29
these creates a new emergency location. So imagine your office is in a multi-tenant building where
1:35
there's multiple floors or multiple companies sharing a space. You can create an emergency
1:41
address with the primary address of that building and then create places within it that show more
1:46
specifically where that user is located, maybe the first floor, the second floor, the third floor
1:52
or maybe you even have a campus of multiple buildings. You can say building A, building B
1:56
building C, etc. So we have one emergency address here and then one place within that emergency address
2:04
Let's go ahead and go into our voice and phone numbers. And I have several phone numbers here
2:11
for both users and conferencing services or auto attendance voice applications like that
2:17
We can see here I have one phone number that's currently assigned to me. So if I select this phone number and click on edit, this phone number is associated with this
2:27
phone number is associated with this emergency location and more specifically the place
2:33
suite 104, within that location. Just real quick, I'm going to cancel that
2:41
and let's search for a city where my emergency locations are created. You can see I could
2:47
select the main address here or I can select the place within it. Let's go ahead and cancel that
2:54
I don't want to make any changes right now. This is one way you can check a phone number's
2:59
emergency location. But as you can see, it doesn't list it here inside the columns that you have to
3:04
scroll through and select each one to see which one they're associated with. This really doesn't
3:09
help us build a report or visibly see where all these phone numbers are associated or report that
3:15
you can easily go take a look at. Another way you can check emergency locations is by going under
3:22
users and manage users and select the user that you want to take a look at
3:31
And within the user profile here, we can see that the emergency address is also here. But again
3:37
it's really hard to be able to go through and audit every single phone number where its associated
3:43
emergency address is and if that phone number is also associated with a user, being able to see
3:48
where their current emergency location is set. Maybe that user has moved to a different floor
3:53
or even a different office location and you want to make sure they're in the right place. This is where using PowerShell can solve this problem of creating a report to verify all that
4:02
information. Let's go ahead and switch over to PowerShell and take a look at how we can do that
4:08
Here we are out in Visual Studio Code. I have a script here called get
4:12
team's emergency address report. I'll include a link to this script out to GitHub and I
4:16
have also written a blog article that goes through this script and I'll also include that
4:21
down in the video description. So to get started, the first command we want to take a look at is
4:25
get cs phone number assignment. This is going to pull back all of our phone numbers that are
4:31
available inside of our tenant. So real quick, I'm just going to select this and press F8 to run just
4:38
that command. And you can see we have quite a few different phone numbers here, all of our service
4:46
and user phone numbers. Here's the phone number that is assigned to me ending in 3750. We can see
4:53
the assigned PSDN target ID that is the GWT for my user account. One thing I want to point out is
4:59
the capability here. We can see that this is a user phone number and it is set to user assignment
5:05
means it will be assigned to users and not like a conference service or a voice application
5:11
Let's find a different example of one of those. Here we have a phone number ending in 0187. Its
5:18
capabilities are conference assignment and voice application assignment. So that's a service phone
5:23
number. So let's take a look at the command that we can run here to just get phone numbers that are
5:30
going to be assigned to users. We can again do get cs phone number assignment. We'll add the
5:36
capabilities contain user assignment because we're only focusing on user phone numbers
5:41
And then we're going to pull back all the results using the top parameter
5:46
And we're going to look at the max value of an integer, which is a very, very high number
5:52
This is the only way you can pull back every phone number. It kind of depends with PowerShell
5:57
Sometimes there's a result size parameter or account or something like that. So let's actually
6:03
just go ahead and run this command. This is going to just pull back fewer phone numbers and they
6:10
should all be user phone numbers, whether they are or are not assigned to a current user. And then
6:17
here in the script, I'm just going to assign all these user phone numbers to user phone numbers
6:22
variable. And then starting on line three, we're going to run through a for each loop. We're going
6:28
to take a look at each of these phone numbers and start pulling back more information. Now
6:33
the first thing we're going to look at here on line four is, is the phone number currently assigned
6:38
to somebody? And we saw that earlier with the assigned PSTN target ID, that phone number that
6:43
was assigned to me that had a value, that value was the GWT for my user account. So that value is
6:49
not null. We are going to then run get CS online user and the identity parameter is that assigned
6:56
PSTN target ID, which is the GWT for my user. And we'll save that to a user variable. If that
7:02
value is null, meaning the phone number is currently not assigned to somebody, I'm going to
7:07
create a custom PowerShell object also called user. And I'm just going to put the display name as not
7:12
assigned and the user principal name as null. And we'll reference those values later. Okay, let's go
7:18
ahead and continue. Next, we need to get the location information that is associated with this
7:23
phone number. So we'll run get CS online LIS location command. And the location ID will be the
7:29
numbers location ID parameter. Let's actually go take a look here like in right here in this example
7:36
of our output from getting the phone numbers earlier, we can see it also has a location ID
7:40
and it's also a GWT associated with the location. Next, let's create the output object that's going
7:47
to contain all the information that we want for our report. So our dollar sign output variable
7:53
this is also a PowerShell custom object, we're going to put the telephone number and pull back
7:58
the telephone number associated with the current number that we're looking at the assigned user
8:03
we got that from our get CS online user command and saved it to the user variable, along with the
8:08
user principal name. And then we're going to take a look at the location ID, the description, and if
8:14
it is currently a place or not. Every LIS location does not necessarily have a place associated with
8:21
it. Because the location could also be just that main address that we took a look at earlier, we
8:26
have the main address. And then if we happen to have a place associated with it, the place for
8:31
that location will also be populated. We've gotten all of our user phone numbers, we've gotten the
8:37
user information if it's associated with the user right now. And then we've gotten the location
8:42
information for that phone number and created our custom output object. So let's go ahead and
8:48
run the script and see what kind of information it pulls back for us. Okay, so we'll just run the
8:55
PowerShell script here. It will take just a few seconds here and it's going to start outputting
9:00
all of our information. So let's go ahead and increase our Windows terminal here. So now we can
9:08
see that this first phone number came up ending in 3681. It's not currently assigned to anybody
9:13
But then we also pull back the location ID, the description of that location, and if it's currently
9:18
associated with a place or not. Let's go ahead and skip down to the one for me, we can see my
9:24
telephone number, it's assigned to me with my UPN, the location ID, the description, which is our
9:28
headquarters office, and this one is associated with a place. But if it wasn't, that would just
9:33
be blank. And then we have the rest of our phone numbers that are currently not assigned to anybody
9:38
and their current location. You can see you could take this, export it out to a CSV file, and then
9:46
be able to take a look at it and verify that everyone's phone number is correct, and then also
9:52
verify where their current emergency address is and if that needs to be updated or not
9:56
Let's actually try that real quick. We'll run this and export to CSV
10:06
Then go ahead and open up the report. We can see it has all the same information we just saw in
10:10
PowerShell, just kind of puts in a table format here. But we can then quickly go through and
10:14
verify all the information, maybe upload it to a Power BI report or anything like that
10:20
That does it for this video. Hopefully you can see how using PowerShell can give you more
10:24
information than what you can find out in the Teams Admin Center, or aggregate that data so you
10:29
can output it to a CSV file or another report that just isn't available out in the Teams Admin Center
10:36
Hopefully you found this useful. Again, check out the video description for links to the script and that blog post. Thanks for watching, and we'll see you next time
10:49
PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell PowerShell
#Business & Industrial
#Computers & Electronics
#Emergency Services
#Enterprise Technology
#Internet & Telecom