PI Services

Le blog des collaborateurs de PI Services

Powershell : Extract Teams phone numbers

Avez vous déjà essayé d'exporter les numéros de Téléphone Teams depuis le portail d'administration ? Je vous en prie faites l'essai... Frustrant non ?

Voici comment exporter les numéros Teams dans un fichier CSV via Powershell

# Variables Definition
$Array = @()
$Csv = "C:\temp\TeamsNumbers.csv"

# Skype Online Connection
Import-Module SkypeOnlineConnector
$sessionCS = New-CsOnlineSession -OverrideAdminDomain assystem.com
Import-PSSession $sessionCS

# Azure AD Connection
Connect-AzureAD

# Collect All Voice User
$AllVoiceUsers = Get-CsOnlineVoiceUser

# Collect Data and store them in array
$AllVoiceUsers | foreach {
    $Name = $_.Name
    $Id = $_.Id
    $SipDomain = $_.SipDomain
    $Number = $_.Number
    $LicenseState = $_.LicenseState
    $UsageLocation = $_.UsageLocation
    $EnterpriseVoiceEnabled = $_.EnterpriseVoiceEnabled

    $CurrentUser = Get-AzureADUser -ObjectId $Id
    $Mail = $CurrentUser.Mail
    $Upn = $CurrentUser.UserPrincipalName

    $Array += New-Object psobject -Property @{
        Name = $Name
        Id = $Id
        SipDomain = $SipDomain
        Number = $Number
        LicenseState = $LicenseState
        UsageLocation = $UsageLocation
        EnterpriseVoiceEnabled = $EnterpriseVoiceEnabled
        Mail = $Mail
        Upn = $Upn     
        }
    $Name = $null
    $Id = $null
    $SipDomain = $null
    $Number = $null
    $LicenseState = $null
    $UsageLocation = $null
    $EnterpriseVoiceEnabled = $null
$CurrentUser = $null
    $Mail = $null
    $Upn = $null
    }

# Export Data
$Array | Export-Csv $Csv -Delimiter ";" -Encoding UTF8 -NoTypeInformation

 

 

Ajouter un commentaire

Loading