0 votes

Hi

When we try to run the below script within adaxes, we get the following error: image.png

Running the script in powershell works fine without errors.

Import-Module MicrosoftTeams

#M365
$msuser = '%username%@xyz.ch' 

#Numbers
$pathFree = "C:\adaxes-scripts\phonesystem\free"
$pathUsed = "C:\adaxes-scripts\phonesystem\used"

#Encryption
$credentialFilePath = 'C:\adaxes-scripts\phonesystem\msteams-SecureStore.txt'
$SecurePwdFilePath = 'C:\adaxes-scripts\phonesystem\msteams-SecureStorePW.txt'
$AESKeyFilePath = 'C:\adaxes-scripts\phonesystem\msteams-AES.key'
$credFiles = Get-Content $credentialFilePath
$username = "admin@xyz.onmicrosoft.com"
$AESKey = Get-Content $AESKeyFilePath
$pwdTxt = Get-Content $SecurePwdFilePath
$securePwd = $pwdTxt | ConvertTo-SecureString -Key $AESKey

#Create M365 Login Credential
$msCred = New-Object System.Management.Automation.PSCredential -ArgumentList $userName, $securePwd

#Connect to M365
Connect-MicrosoftTeams -credential $msCred

$phone = Get-CsOnlineUser -Identity $msuser | select -expand LineUri
$Context.LogMessage("$phone", "Information")
if($phone -ne "") {
    #$phone = $phone.TrimStart('')
    $Context.LogMessage("$phone", "Information")
    $usedNumberFile = $pathUsed+'\'+$phone+'.txt'
    $Context.LogMessage("$usedNumberFile", "Information")
    Move-Item $usedNumberFile -Destination $pathFree -force
}

Disconnect-MicrosoftTeams

Clear-Variable -name phone
Clear-Variable -name usedNumberFile
Clear-Variable -name msCred

Any ideas why Adaxes doesnt liek that script? Thanks

by (80 points)

1 Answer

0 votes
by (272k points)

Hello,

Unfortunately, this is a known issue when working with Microsoft Teams using PowerShell. The issue is not related to Adaxes. It occurs because recent updates to the corresponding PowerShell module were not fully completed. Unfortunately, there is no workaround or fix. However, you can try using an old version of the module, e.g. 2.3.2.

Related questions

0 votes
1 answer

Hi there, i've a custom command with multiple powershell scripts (for clearance reasons). If for example the frist script produces an error i Write an Error but the next ... tried with an simple exit 1; I only Write-Errors on issues. Kind regards, Constantin

asked Jul 23, 2021 by Constey (190 points)
0 votes
0 answers

Hi, I recently set up a business role per a post in this thread that creates an on-prem shared mailbox and then moves that mailbox to O365. The issue is that ... ("Mailbox move request created successfully. Check Exchange logs for details." , "Information") }

asked Sep 14, 2016 by ajrechk (480 points)
0 votes
1 answer

I'm using the example from the following SDK page: http://www.adaxes.com/sdk/ManagingSecurityRoles.html # Allow: Reset Password -> User $entry = $role.Permissions.Create() ... from the example. What am I missing here? Thanks for any help you can provide

asked Nov 16, 2015 by drew.tittle (810 points)
0 votes
1 answer

I am having an issue running a powershell script through Adaxes. I am trying to have this run as a business rule when ... $optoffice.DisabledServicePlans = "ONEDRIVESTANDARD" Set-MsolUserLicense -UserPrincipalName %userPrincipalName% -LicenseOptions $optOffice

asked Mar 2, 2015 by malsobrook (50 points)
0 votes
1 answer

Hello, I am trying to figure out how to create a scheduled task via PowerShell. I've been referencing the SDK, mostly pulling script examples straight out of it. After following the steps on ... ==================> # Save the Scheduled Task $task.SetInfo()

asked Feb 23, 2015 by DFassett (710 points)
3,354 questions
3,054 answers
7,795 comments
545,127 users