0 votes

So I need to export a list of all user's Line URI's to a CSV file. Running Adaxes 2021 Version 3.14.18804.0 (64 bit) and Teams Powershell 4.1.0

It works OK doing this manually through Powershell as follows:

get-csonlineuser | where-object {($_.UsageLocation -eq "NZ") -and (($_.Company -eq "ourcompanyname") -or ($_.Company -eq "ourothercompany")) -and (($_.City -eq "Auckland") -or ($_.City -eq "Wellington")) -and ($_.AccountEnabled -eq "True") -and ($_.Title -ne "contractor")} | select userprincipalname,Company,City,LineURI | Sort-Object -Property Company,City,LineURI,userprincipalname
| export-csv c:\temp\teamsusers.csv

However when I put it into Adaxes as follows it does not work. Can someone please advise what I need to do to make this work?


# Get saved credentials
$username = $Context.RunAs.UserName
$password = $Context.RunAs.Password | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PsCredential($username, $password)

try
{
    #Connect to Teams and export a list of staff to CSV file
   Connect-MicrosoftTeams -Credential $credential

   get-csonlineuser | where-object {($_.UsageLocation -eq "NZ") -and (($_.Company -eq "ourcompany") -or ($_.Company -eq "ourothercompany")) -and (($_.City -eq "Auckland") -or ($_.City -eq "Wellington")) -and ($_.AccountEnabled -eq "True") -and ($_.Title -ne "contractor")} | select userprincipalname,Company,City,LineURI | Sort-Object -Property Company,City,LineURI,userprincipalname | export-csv c:\temp\teamsusers.csv
}

catch
{
    return # The user doesn't have a Microsoft 365 account
}

finally
{
    # Close the connection and release resources
    Disconnect-MicrosoftTeams
}
by (180 points)
edited by
0

Hello,

What exactly do you mean by does not work? Do you face any error messages? If you do, please, post here or send us (support@adaxes.com) screenshots. Also, please, make sure that there is only the latest version of the Microsoft teams PowerShell module installed on the computer where Adaxes service runs.

Please log in or register to answer this question.

Related questions

0 votes
1 answer

Receive "Index operation failed; the array index evaluated to null. Stack trace: at <ScriptBlock>, <No file>: line 104>" and "Index operation failed; the ... $GroupName, $GroupDN." } } #foreach write-output "" Write-Output "" Stop-Transcript

asked Apr 14 by jbahou (20 points)
0 votes
1 answer

Hello I'm trying to run a custom PowerShell script to request a Workspace ONE Access Sync when I change something in our users or groups. Here is the script: $ClientId = "api ... of having to create 6 independent rules with each of them a copy of the script)?

asked Sep 25, 2021 by ygini (220 points)
0 votes
1 answer

Hello, is it possible to add computers to the basket, imported from a csv file? We get a list from our client team to disable computer accounts in bulk. regards Helmut

asked Feb 22, 2021 by a423385 (510 points)
+1 vote
1 answer

I am trying to connect to teams via powershell in adaxes to run the following commands. Set-CsUser -Identity <UPN> -EnterpriseVoiceEnabled $true -HostedVoiceMail $true ... (policyname)" I am not able to run the following though, Connect-MicrosoftTeams

asked Apr 22, 2021 by TJ_Umredkar (140 points)
0 votes
1 answer

When I create a user from adaxes I also want it to be added to MS Teams groups. At this moment i create the account in adaxes after that i need to add this user in all groups that we have in MS Teams so i what to automate this when i create a new usuer.

asked Mar 29 by abisaigomezm (40 points)
2,803 questions
2,535 answers
6,605 comments
62,057 users