Fail to run if -Button is excluded
yokhoe opened this issue · 10 comments
When trying to create a section without including a button, it seems to fail to run.
Can you provide example?
Sure. I could recreate it using your example.
$Section3 = New-TeamsSection
-ActivityTitle "**Przemyslaw Klys**"
-ActivitySubtitle "@PrzemyslawKlys - 9/12/2016 at 5:33pm"-ActivityImage Add
-ActivityText "Climate change explained in comic book form by xkcd xkcd.com/1732" `
-ActivityDetails $Fact3, $Fact4, $Fact5, $Fact6, $Fact7, $Fact8, $Fact9, $Fact10, $Fact11
I can't reproduce it:
Clear-Host
if ($PSEdition -eq 'Core') {
Import-Module PSTeams -Force -SkipEditionCheck #-Verbose
} else {
Import-Module PSTeams -Force
}
## https://docs.microsoft.com/en-us/microsoftteams/platform/concepts/cards/cards-format
## https://docs.microsoft.com/en-us/outlook/actionable-messages/message-card-reference
$TeamsID = 'myteamsid'
$Color = 'Chocolate'
$Button1 = New-TeamsButton -Name 'Visit English Evotec Website' -Link "https://evotec.xyz"
$Button2 = New-TeamsButton -Name 'Visit Polish Evotec Website' -Link "https://evotec.pl"
$Fact1 = New-TeamsFact -Name 'Bold' -Value '**Special GPO**'
$Fact2 = New-TeamsFact -Name 'Italic and Bold' -Value '***Other values***'
$Fact3 = New-TeamsFact -Name 'Italic' -Value '*2010-10-10*'
$Fact4 = New-TeamsFact -Name 'Link example' -Value "[Microsoft](https://www.microsoft.com)"
$Fact5 = New-TeamsFact -Name 'Other link example' -Value "[Evotec](https://evotec.xyz) and some **bold** text"
$Fact6 = New-TeamsFact -Name 'This is how list looks like' -Value "
* hello
* 2010-10-10
* test
* another
* test
* hello"
$Fact7 = New-TeamsFact -Name 'This is strike through example' -Value "<strike> This is strike-through </strike>"
$Fact8 = New-TeamsFact -Name 'List example with nested list' -Value "
- One value
- Another value
- Third value
- Fourth value
"
$Fact9 = New-TeamsFact -Name 'List example with a twist' -Value "
1. First ordered list item
2. Another item
* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
1. Ordered sub-list
2. Another entry
4. And another item.
"
$Fact10 = New-TeamsFact -Name 'Code highlight' -Value "This is ``showing code highlight`` "
$Fact11 = New-TeamsFact -Name '' -Value "
### As you see I've not added Name at all for this one and it merges a bit with Fact 10
This is going to add horizontal line below. While this line is highlighed.
---
And a block quote
> Block quote
# H1
## H2
### H3
#### H4
##### H5
###### H6
"
$Section1 = New-TeamsSection `
-ActivityTitle "**Przemyslaw Klys**" `
-ActivitySubtitle "@przemyslawklys - 9/12/2016 at 5:33pm" `
-ActivityImageLink "https://github.com/EvotecIT/PSTeams/blob/master/Images/10.png?raw=true" `
-ActivityText "Climate change explained in comic book form by xkcd xkcd.com/1732" `
-ActivityDetails $Fact1, $Fact2
$Section2 = New-TeamsSection `
-ActivityTitle "**Przemyslaw Klys**" `
-ActivitySubtitle "@przemyslawklys - 9/12/2016 at 5:33pm" `
-ActivityImageLink "https://pbs.twimg.com/profile_images/1017741651584970753/hGsbJo-o_400x400.jpg" `
-ActivityText "Climate change explained in comic book form by xkcd xkcd.com/1732" `
-ActivityDetails $Fact3, $Fact4, $Fact5, $Fact6, $Fact7, $Fact8, $Fact9, $Fact10, $Fact11
$Section3 = New-TeamsSection `
-ActivityTitle "**Przemyslaw Klys**" `
-ActivitySubtitle "@przemyslawklys - 9/12/2016 at 5:33pm" `
-ActivityImage Add `
-ActivityText "Climate change explained in comic book form by xkcd xkcd.com/1732" `
-ActivityDetails $Fact3, $Fact4, $Fact5, $Fact6, $Fact7, $Fact8, $Fact9, $Fact10, $Fact11
Send-TeamsMessage `
-URI $TeamsID `
-MessageTitle 'Message Title' `
-MessageText 'This is text' `
-Color Chocolate `
-Sections $Section2, $Section1 -Verbose
Send-TeamsMessage `
-URI $TeamsID `
-MessageTitle 'Message Title' `
-MessageText 'This is text' `
-Color DodgerBlue `
-Sections $Section3 -Verbose
Hmm... let me get back to you. I am currently testing on VSCode in MacOS Mojave. I'll try to get on a Win10 workstation and test again. Perhaps there are some discrepancies. Thanks for getting back so quickly.
I've added a simplified test (without button) - https://github.com/EvotecIT/PSTeams/blob/master/Tests/Send-TeamsMessage.Tests.ps1 and currently it's running as part of AzureDevOps on Ubuntu/Mac/Windows... we should know whether this is not working on any of the platforms.
Ok, problem found. Sending new code, will publish soon.
Please use
Update-Module PSTeams
Should fix your issue. It should also be faster to load as I've published as single psm1 (as per my article: https://evotec.xyz/powershell-single-psm1-file-versus-multi-file-modules/).
Thanks for reporting this.
Thanks for fixing. Should've checked my PSCore version.
It wouldn't matter. The issue was that $null seems to be bad idea for PS6. PS5.1 was working fine with it. Simple fix :-)