Help to schdeule a MS Teams Script

Ramki 816 Reputation points
2022-02-07T06:12:30.757+00:00

i have a MS Teams script with working fine, howeever i would like schdeule in task to run the script on evary day in a task schedular , i have a servcie account, with no MFA enabled . how to do it

i try to secure the password and called it , it is keep giving the below errror

Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "D:\ra\Password.txt"

$TenantUname = "ram@dqw.com"
$TenantPass = cat "D:\ra\Password.txt" | ConvertTo-SecureString
$TenantCredentials = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $TenantUname, $TenantPass
Connect-MicrosoftTeams -Credential $TenantCredentials

Connect-MicrosoftTeams : One or more errors occurred.: unknown_user_type: Unknown User Type
At line:1 char:1

  • Connect-MicrosoftTeams -Credential $Credentials
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AadAuthenticationFailedException
  • FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

Connect-MicrosoftTeams : One or more errors occurred.
At line:1 char:1

  • Connect-MicrosoftTeams -Credential $Credentials
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AggregateException
  • FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

Any help would be much apprcaited

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
9,627 questions
Microsoft Teams Development
Microsoft Teams Development
Microsoft Teams: A Microsoft customizable chat-based workspace.Development: The process of researching, productizing, and refining new or existing technologies.
3,065 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ramki 816 Reputation points
    2022-02-09T04:56:58.357+00:00

    Hi i followed this instrcution from the below link and workinfine

    https://practical365.com/saving-credentials-for-office-365-powershell-scripts-and-scheduled-tasks/

    1 person found this answer helpful.