Casting Type Error

Hi,

I am using Invoke Powershell activity to Connect Teams and retrieve unassigned telephone number. But, while running the code I am facing a type casting error says:

Invoke Power Shell: Unable to cast object of type ‘Microsoft.TeamsCmdlets.Powershell.Connect.Models.PSAzureContext’ to type ‘System.Management.Automation.PSObject’.

How to import this type in UiPath Studio. Suggests some idea

Thanks,

Hi @john.mari ,
Welcome to UiPath Community.

To resolve this issue, you may need to add a reference to the assembly that contains the required type in UiPath Studio.
You can follow these steps to get the solution.

  • Open your UiPath project in UiPath Studio.
  • Navigate to the “Imports” panel on the left-hand side of the Studio interface.
  • Click the “Browse for Types” button.
  • In the search box, type “Microsoft.TeamsCmdlets.Powershell.Connect.Models.PSAzureContext” and press Enter.
  • Select the desired assembly containing the type from the search results and click “OK”.
  • Save your changes.

If this helps you, please mark it as a solution :writing_hand:
Happy Automation :grinning:

Regards,
@pratik.maskar

I tried the method you suggested, but the namespace not showing under the import

Hi @john.mari ,

If you are not able to find the necessary module or namespace when trying to import it in UiPath Studio, it’s possible that the module is not installed on your system, or that it is not available in the default PowerShell repository.
If the necessary module is not installed, you can try installing it using the `Install-Module command in PowerShell

Regards,
@pratik.maskar

We already installed the Microsoft-Teams module using PowerShell.