Hi,
I’ve been spending the last weeks trying to solve this problema about creating a Microsoft Teams team, then adding some members, then doing something else, but I haven’t succeeded yet because of some problems I haven’t been able to solve (for more info, track my latest messages in the forum).
Currently I’m using the “Invoke Power Shell” activity, using one for each PowerShell command I have to execute in order to complete the seqüence, as I am using the module for PowerShell provided by Microsoft to automatize Teams functions:
-
- “Connect-MicrosoftTeams” → in order to connect/authenticate on Teams with a user account. It opens a dialog for a Teams account, with a user and password prompte.
-
- “New-Team” → command for creating a team. Yo must provide some information, about the owner, team name, etc.
-
- “Add-TeamUser” → After the previous command has successfully executed, you should get an Id of the newly created group, and pass it to this command, along with a list of members, to add them to the group.
Well, I’m stuck halfway accross 2) and 3) because I cannot extract the Id from 2) because the returned object with that property is of a type UiPath doesn’t provide support to and I haven’t been able to avorcome it in a feasible way.
Now my attempt is to run 2) inside an script which would do the same as “New-Team” but also extract the Id from the newly created team and return it as the output of the script, and call that script in a PowerShell activity.
I’m having a hard time accomplishing so because in UiPath the script gets lauched in half a second (proving that it didn’t work well), then continues to the next activity and I get nothing in the result variables.
Apart from being hard to debug, when I try to run the script “by hand” via CMD on Windows to help debugging, I get the message that
Error: You must call the Connect-MicrosoftTeams cmdlet before calling any other cmdlets.
Which is reasonable, but the thing is that if I run a Connect-MicrosoftTeams prior to it, then I run my script, it still complains about the same.
My impression is that, when executing the commands one after another via the PowerShell activity, UiPath keeps a kind of “session” that makes them aware that the “context” is still the same and the previous “Connect-MicrosoftTeams” has been executed and the session is active.
Does anyone know what’s the way to go? Of course I understand that, probably putting all the sequence of commands inside ONE only script it should work, but I prefer to keep them as “modular” as possible, keeping any command in its own activity, to make it easir to debug and trace any errors, etc.