10-06-2023 12:00 PM
Hi everybody,
I'd like to know if there is a way to get the work phone and work mobile phone using Get-JCUser powershell command or if I need to use another way.
Actually I'm using this script to get some data:
# Get All Users
$users = Get-JCUser
# Store all user properties + calculated "managerUsername" in a new variable called $list
$list = $users | Select-Object suspended, id, firstname, lastname, jobTitle, username, email, displayname, department, employeeIdentifier, employeeType, @{ Name = 'ManagerUsername'; Expression = { (Get-JCUser -userid $_.manager).Username } }, @{ Name = 'Manager_ID'; Expression = { (Get-JCUser -userid $_.manager).ID } }
# Export $list as a csv
$list | ConvertTo-Csv | Out-File ./users_managers_organization.csv
And I'd like to add user work phone and work mobile phone, if possible.
Thanks a lot
Dario
Solved! Go to Solution.
10-11-2023 01:22 AM - edited 10-11-2023 01:23 AM
Thanks @urvashi for calling, so i would calculate the numbers' field like this:
$users =Get-JCUser
$list = $users | select @{name="mobileNum";Expression ={( $_.phoneNumbers[0].number)}},@{name="WorkNum";Expression ={( $_.phoneNumbers[1].number)}}
feel free to concatenate the rest of the attribute you wanted to select if ^ works.
10-09-2023 10:30 AM
Hi Dario, I'm looking into this. I'll get back to you ASAP.
10-10-2023 09:29 AM
Hi @dariovernelli phone numbers are available under
Get-JCUser -returnProperties phoneNumbers
Hope this helps 🙂
10-10-2023 09:46 AM
Hi @urvashi ,
I'll check immediately...
10-10-2023 10:29 AM - edited 10-10-2023 10:30 AM
Hi @urvashi,
the -returnProperties returns
{@{type=work_mobile; number=+39 1234567; _id=637d00f47419xxxxxxxxx}, @{type=work; number=+39 124234556; _id=637d00f47xxxxxxx}}
and there are the info what I'm looking for. Now I have to understand how to extract the numbers and put the expression into my query and put the results to csv.
I don't know how to use the "Expression" function...
10-10-2023 11:33 AM
That's where I got stuck too. @shawnsong could you help us figure out how to extract those values?
10-11-2023 01:22 AM - edited 10-11-2023 01:23 AM
Thanks @urvashi for calling, so i would calculate the numbers' field like this:
$users =Get-JCUser
$list = $users | select @{name="mobileNum";Expression ={( $_.phoneNumbers[0].number)}},@{name="WorkNum";Expression ={( $_.phoneNumbers[1].number)}}
feel free to concatenate the rest of the attribute you wanted to select if ^ works.
10-11-2023 03:49 AM
10-11-2023 04:03 AM
You are most welcome @dariovernelli 😉
10-11-2023 09:47 AM
Thank you @shawnsong!
New to the site? Take a look at these additional resources:
Ready to join us? You can register here.