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 (294k 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

Trying to create a custom command to run a powershell script, but I keep getting an error saying it can't find the file or path supplied for launching powershell. ... and I can launch powershell from this location using Command Prompt. Am I missing something?

asked Oct 24 by cstaub (100 points)
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)
3,589 questions
3,278 answers
8,303 comments
548,123 users