Certain toast messages cause an error until server restart
Describe the Bug
Certain toast messages cause an error until server restart
Steps To Reproduce
New-PodeWebSelect -Name 'SQLServer:' -Options @($Servers) | Register-PodeWebEvent -Type Click -ScriptBlock {Show-PodeWebToast -Title "Unsupported" -Icon "message-alert-outline" -Message "This value is hard-coded to SPN-SC1D-SQL.nacloud.ecihosting.com for this example"}
Expected Behavior
Toast message wouldn't update unit the next restart, but it shouldn't produce an error.
Screenshots
Platform
- OS: Windows Server 2019 Standard
- Browser: Edge Version 130.0.2849.46
- Versions:
- Pode: v2.9.0
- Pode.Web v0.8.3
- PowerShell v7.4.5
Additional Context
I noticed this issue when I changed the name of the server from "SCN-SC1-CVSQL1" to "SPn-SC1d-SQL.NACloud.ecihosting.com" I'm guessing based on the error message and the reference to Utilities.ps1 lines ~530 that the issue has to do with the periods in the message. It seems to work fine once the server restarts, but I thought it was weird enough to look into.
Sorry I should have put his on the Pode.Web repo.
Hi @KeithALane,
Looking at the error/stacktrace, the error seems to be being thrown from Invoke-SqlCmd. I'm guessing this is what's inside you're actual scriptblock?
There could be DNS conflict somewhere if you're changed the server name, and Invoke-SqlCmd is using the old name until the server is restarted 🤔
For any one who might land on this issue because of a similar problem, this message 'Incorrect syntax was encountered while parsing ''.' is a generic message from Invoke-SqlCmd and most often happens when there was a failure to connect to the server. This isn't so much a network issue as if you have a DNS issue or incorrect host name you get a different error. The most common reason I see this error is because MS has changes the encrypted connection setting in recent version of .NET. Previously encrypting the connection to SQL server was disabled by default. Now it is enabled by default, If you have not setup encrypted connections on your SQL server (a real pain in the ...) your connection will fail. You have to provide the -Encrypt parameter and set it to 'Optional'. You can set this as a default parameter in your profile by adding this to your profile script.
$PSDefaultParameterValue["*SQL*:Encrypt"] = 'Optional'
I would avoid depending on this for a Pode.Web app. Put SQL Server parameters in your Server.psd1 file.
There are many other Gotchas when using the SQL Server module and specifically Invoke-SqlCmd with Pode.Web. There are some simple workarounds I have discovered that I'll write up in a discussion post (does anyone read these?)