Powershell-Script in SCOM-Server does not recogniz Connect-MicrosoftTeams cmdlet

Freddy Neuhaus 21 Reputation points
2021-07-26T14:05:08.963+00:00

Hi there

Since 6 months we use a power-shell script in SCOM to check and to modify some telephone numbers in Teams.
Of course, we use Connect-MicrosoftTeams cmdlet.
It worked fine.
But since today, we have this error:

The term 'Connect-MicrosoftTeams' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Reboot server(of course ;))
If I us this cmdlet with my personal account it works.
If I login with the service-account running the runbook, the cmdlet works.
'Reinstall' of the module
Retyping it in the powershell-command in SCOM, if there is any issue after copy/paste (for example, we had lost many special characters during copy/past-error)

Since it still doesn't work, i'm asking for your advice.

Best Regards
Freddy

Operations Manager
Operations Manager
A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.
1,482 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,527 questions
0 comments No comments
{count} votes

Accepted answer
  1. XinGuo-MSFT 18,081 Reputation points
    2021-07-27T07:49:31.59+00:00

    Hi,

    SCOM =System Center Operations Manager
    SCO = System Center Orchestrator

    Based on my understanding, our question is related to the SCO.

    The first consideration is to check the current PowerShell version in Orchestrator. By default, the Run .Net Script activity runs scripts with PowerShell 2.0, which lacks many features of newer versions.

    https://social.technet.microsoft.com/wiki/contents/articles/30721.powershell-system-center-orchestrator-best-practice-template.aspx

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Stefan Horz 3,466 Reputation points
    2021-07-27T09:52:26.31+00:00

    Hi @Freddy Neuhaus ,

    I guess your post is related to Operations Manager (SCOM) not to Orchestratorl. So the wuestion will be better in: https://learn.microsoft.com/en-us/answers/topics/msc-operations-manager-general.html

    Nevertheless I guses this will help you: scom-action-account-cannot-run-powershell-cmdlet-within-scom-but-can-outside-of-scom

    Regards,
    Stefan

    0 comments No comments

  2. Freddy Neuhaus 21 Reputation points
    2021-07-28T12:01:18.687+00:00

    Hi there

    My bad, it System Center 2019 Orchestrator :-)

    I'm going to try invoke command to localhost, as suggested by XinGuo-MSFT

    BR,
    Freddy

    0 comments No comments

  3. Freddy Neuhaus 21 Reputation points
    2021-07-29T06:37:00.67+00:00

    Thanks @XinGuo-MSFT
    Merged our script with the template, working fine.

    By change I found:
    https://social.technet.microsoft.com/Forums/lync/en-US/bda22a17-c274-4799-9624-97588fdf4357/orchestrator-2016-powershell-not-importing-modules?forum=scogeneral

    "...make "Run .Net Script" Activity to exceute the available version of PowerShell on the Orchestrator Runbook Server:..."

    Best Regards
    Freddy


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.