Posting to MS Teams Issue

I have added a Microsoft Teams step to my deployment process. When I attempt to make a deployment the post to MS Teams fails. I have it configured with the correct Webhook URL and it is set to run on the Octopus server.

Here are the important bits from the raw log (full log attached).

11:44:33   Error    |       The term 'ConvertTo-Json' is not recognized as the name of a cmdlet, function,
11:44:33   Error    |       script file, or operable program. Check the spelling of the name, or if a path
11:44:33   Error    |       was included, verify that the path is correct and try again.
11:44:33   Error    |       At C:\Octopus\Work\20170329184430-3\Script.ps1:3 char:23
11:44:33   Error    |       + $json = ConvertTo-Json <<<<  -Compress -InputObject @{"title" = $Title; "text
11:44:33   Error    |       " = $Body; }
11:44:33   Error    |       + CategoryInfo          : ObjectNotFound: (ConvertTo-Json:String) [], Pare
11:44:33   Error    |       ntContainsErrorRecordException
11:44:33   Error    |       + FullyQualifiedErrorId : CommandNotFoundException

ServerTasks-9619.log.txt (7 KB)

Hi,

Thanks for getting in touch! From your logs it looks like the machine you are running this script on only has PowerShell 2.0 (see the PSVersion line in the logs) and I believe ConvertTo-Json was only added in PowerShell 3.0. You’ll need to either update PowerShell on that machine, or if you check Google it looks like a few people have had a go at writing a PS2 implementation of ConvertTo-Json that you could try.

I hope that helps.

Mark

Thanks for the quick reply! Upgrading to PowerShell 3.0 fixed my issue.