-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set-Variables.ps1 script Unexpected token '?' in expression or statement #150
Comments
Hi @henrydyer, I just followed our instructions and see the output, as expected, as Could you double-check your steps, please, and inform us what PowerShell version you are using? |
Hi Simon, thanks for getting back to me so quickly! Here’s my version info:
Name Value
---- -----
PSVersion 5.1.19041.4046
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.19041.4046
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
It was doing the same before I upgraded though. I can’t recall the exact version I had previously, but it was 4.x.x. My first thought was that I needed to update PS.
I just re-copied the code for the script and tried again. It’s odd that it seems to have no issue running the actual variable setting part, but just struggles with formatting the output.
From: Simon Kurtz ***@***.***>
Sent: Friday, February 23, 2024 6:48 PM
To: Azure/aca-dotnet-workshop ***@***.***>
Cc: Henry Dyer ***@***.***>; Mention ***@***.***>
Subject: [EXT] Re: [Azure/aca-dotnet-workshop] Set-Variables.ps1 script Unexpected token '?' in expression or statement (Issue #150)
Hi @henrydyer, I just followed our instructions and see the output, as expected, as Wrote 1 variable to ./Variables.ps1. I run PowerShell 7.4.1.Could you double-check your steps, please, and inform us what PowerShell version you are using?—Reply to this email directly, view
<https://us.report.cybergraph.mimecast.com/alert-details/?dep=JHYo%2BWDWvr66YlzVcg4AvA%3D%3D%2BcTteGL8aDNnYU8fwJv20tarjgo0RF6d3BxhMY9nkSY62F62yS5CMsYHCa0cRxxXgQX2y2mxtNH3wS6mXBTHTHgq8dTKtQbcBrQVSuvit1QaA3s3zl9tj52pjp6KvsAiIpruR7mB45p1vr75NlIGwNKNuGU3YPHQ3wnlv8kvPEaPivUYLqHtlADXsjzg%2FfdOnHcfUztphh5wO7NG%2Fz2G6iaSvuEXoojA1kbr6btcVfzX7gUHmRm75d3f3mjz7Yrw%2FBMtLMuNOv3Y7p%2BykHeU%2FRUGsUuDnZHw5NS%2Fug056XYO%2Ffg2Jt7RrSaICkTiW6lSlDoouxsAtKoTH3ekwj42jTH2XZLnX8NrYJhqNqzYbu%2Fxw0PEjDgn82KIBrS8C3l6%2BR6SGpBg2d8Qr2NnUMqCYnSPAY8lttZb7BNsFJbSh89sCtTMS2RUTTaKcTJUBeXYb8aPOtPQgkT%2B7jlb1EXSQHB0Citi8U2Ks67VOfg84Mi4oUnkqWsox0v4r%2BDMNlAaz1GzVfDIn%2BDnWS9wm1XH5Hna2Sq5jUMDxHKaa4s35TOAxVOt5F0Dqjoc05qcb82T8Gh5Phzz%2BtSywFX7pH60JYhTVcixwABUVB%2B8UltI7%2FyhrchksIztZVJIzl6L%2BnqdSSYJwMUg%2FuHXKLEh7xV0wBuCkggo2%2F56zGJjy31PC98dwh72akqc96EqvG%2Ff80Jyd1B6G8HK3WqpcqIA3UAPHiimAABGu2K1W4GoYLrKSPxAtS9spurwCPbWpkBT7jbQvp1HBR0mnME2Tw4pK3W55PpQ%2FuMRM8oloMuFynZcWxm9sv3fOsUfnBjoHpfF7WtOVTU0jeGwb7p9XOPkuzmEQBUn%2F%2BeZuYb%2FoIdSVnSSPx34e3tc2XZaqHusU7%2F5S0vmO3eMjSPaW1%2F5aAo0H4faJpLeSFTu5UF%2BB5X95gGzZYglA%2BiqQr81vaRlbeoLCyLt>
Hi @henrydyer<https://github.com/henrydyer>, I just followed our instructions<https://azure.github.io/aca-dotnet-workshop/aca/00-workshop-intro/4-prerequisites> and see the output, as expected, as Wrote 1 variable to ./Variables.ps1. I run PowerShell 7.4.1.
Could you double-check your steps, please, and inform us what PowerShell version you are using?
—
Reply to this email directly, view it on GitHub<#150 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABWIWBPX3FKJOLAVYBFAJGTYVDP6FAVCNFSM6AAAAABDXESZWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRHAZDKMBSGU>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Hi @henrydyer, you are welcome! I'm so sorry you are running into trouble there. I have fairly exclusively run this on PowerShell 7 in Windows 11, so I can't speak to 5.1 on Windows 10 much. Given that this seems to revolve around an informative console output only and perhaps not the core functionality, could you try to comment it out and see if everything else from there on goes as desired, please? If you are so inclined, I would also love a PR if you tinker with the output and get it working. Thank you! |
Hi Simon, no worries! I have made some progress in that I can run the script from the VS Code terminal without issue, it just doesn’t work from a standalone PS terminal window.
The output I get in the Code terminal is “Wrote 1 variable to ./Variables.ps1.”, and it generates the following in Variables.ps1:
# Execute with "./Variables.ps1" to restore previously-saved variables.
Set-Variable -Scope Global -Name TODAY -Value (Get-Date -Format 'yyyyMMdd')
Write-Host "Set 1 variable."
I assume this is correct, as none of the other variables have actually been set yet.
So it sounds like my issue is just down to version incompatibilities. If I make any other discoveries, I’d be happy to raise a PR of course.
Thanks for your help.
From: Simon Kurtz ***@***.***>
Sent: Monday, February 26, 2024 12:08 PM
To: Azure/aca-dotnet-workshop ***@***.***>
Cc: Henry Dyer ***@***.***>; Mention ***@***.***>
Subject: [EXT] Re: [Azure/aca-dotnet-workshop] Set-Variables.ps1 script Unexpected token '?' in expression or statement (Issue #150)
Hi @henrydyer, you are welcome! I'm so sorry you are running into trouble there. I have fairly exclusively run this on PowerShell 7 in Windows 11, so I can't speak to 5.1 on Windows 10 much. Given that this seems to revolve around an informative console output only and perhaps no
<https://us.report.cybergraph.mimecast.com/alert-details/?dep=JJB6OX0YEYXFDVZtGcz4DA%3D%3DCvF%2BIjqNLglJ1iH4m8MzUp3ue1IUIf4ANI6BKlCca0tgq7v8OcrwT7Bt92KrCfQ1GCUy7siT0ugm5B6inCLomgrD0hEb65jAdtm3dfVTKfxVxjcNn75VYJYNLApmHBiGRkaxoQoYTvJNeJFPTDdCR4eQeBwNmNZwLbOcd1TZQE6V%2BANoYbu62iGBvgmlUO7Qkt%2F8oYYF0oLM0ewHG2bCw%2FUSDkcXvYck719GqxlfzEtTeYRtNQLyQHB83eI8Z109GF5teamaYCsdODFqWrSyOPTAFY1TgXPvHbTXVfQl5Rp%2B11ndrLrL845jOQO51y8SepvPkq3LLQHfAn7UEgrVEOffmBSb4uxDpthgw%2B4ncqqnoDXKmcBcpesbE8y4muuM54QBC774Yyky1e9RVt8Mf765FLOXDK8aVuThAUAqE0YWKec51L9Mlh3Fb4X%2BqL4dnGtc%2FuBk%2Bd3vUsg5wb3RFM1saJlZ4mj3yzrccaezGMpUyrMdYzVPl4ZZJpAaPHU5baLgHAYFKc7ny1jzKGUJUQJlc76h98jy3%2BxAf4lHJZjbzbgDKibcZZ4GyuaQLcigoGcfACsi04SnBoxirI1aX7OukhF6gLZd44fR4wHEP2TtDkKnisDAnG1%2Fs5e9O3HHMVDahz56hwrm9gu1f7Fosp%2B5IMugHWSfZ9d5Ts9qd5qSSNI%2BXeJkvIi6EcoKE1TsSeqrugpr9UEaR0c0lxgEmXDIA8se6QgQ5ZXBB%2FJOSGxtMZn%2FWqvkQ6syB83rFtTOiJrunZa%2BsKSZAG2sX0aR9yqP0dJ94umgFWiU6wf9g57upkyHN1Am5ybu2lq5TZVERR3JkEJ2qEtDtZdngmMQlP3WbNeIJXFa6wNXee%2Fic2Wt8kZj27GBwTY6lO2ErQikxDkbTEsbSeXAReJzRMlVpTxgmCONw9JkFU5SuzU32UoplYAYdP9uTXDwH5GJHN3W>
Hi @henrydyer<https://github.com/henrydyer>, you are welcome! I'm so sorry you are running into trouble there. I have fairly exclusively run this on PowerShell 7 in Windows 11, so I can't speak to 5.1 on Windows 10 much. Given that this seems to revolve around an informative console output only and perhaps not the core functionality, could you try to comment it out and see if everything else from there on goes as desired, please? If you are so inclined, I would also love a PR if you tinker with the output and get it working.
Thank you!
—
Reply to this email directly, view it on GitHub<#150 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABWIWBKBRDNXM5JHCOZLH5DYVR3JNAVCNFSM6AAAAABDXESZWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRTHE4TKMJRGM>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Hi @henrydyer, awesome progress! It looks like you are running into a difference between Windows PowerShell built on .NET Framework and the open-sourced PowerShell built on .NET Core. It appears that your VS Code is using the newer PowerShell version via its extension. I typically use Windows Terminal and PowerShell in my setup. Not to get too much beyond the filed issue, but it may be worthwhile for you to explore whether that setup could provide some advantages. I'll keep the issue open, but I don't expect to do any active development on it as it's a relatively benign issue, all-in-all, and a work-around exists. I thank you for filing it, and I hope that you enjoy working with Azure Container Apps! Reach out if you have any questions, please. |
OK, thanks very much!
From: Simon Kurtz ***@***.***>
Sent: Monday, February 26, 2024 1:15 PM
To: Azure/aca-dotnet-workshop ***@***.***>
Cc: Henry Dyer ***@***.***>; Mention ***@***.***>
Subject: [EXT] Re: [Azure/aca-dotnet-workshop] Set-Variables.ps1 script Unexpected token '?' in expression or statement (Issue #150)
Hi @henrydyer<https://github.com/henrydyer>, awesome progress!
It looks like you are running into a difference between Windows PowerShell built on .NET Framework and the open-sourced PowerShell built on .NET Core<https://learn.microsoft.com/en-us/powershell/scripting/whats-new/differences-from-windows-powershell?view=powershell-7.4>. It appears that your VS Code is using the newer PowerShell version via its extension<https://code.visualstudio.com/docs/languages/powershell>.
I typically use Windows Terminal<https://learn.microsoft.com/en-us/windows/terminal/install> and PowerShell in my setup. Not to get too much beyond the filed issue, but it may be worthwhile for you to explore whether that setup could provide some advantages.
I'll keep the issue open, but I don't expect to do any active development on it as it's a relatively benign issue, all-in-all, and a work-around exists. I thank you for filing it, and I hope that you enjoy working with Azure Container Apps! Reach out if you have any questions, please.
—
Reply to this email directly, view it on GitHub<#150 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ABWIWBI3BSRYUZKKFLG2MHDYVSDG3AVCNFSM6AAAAABDXESZWSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRUGEZDAOBYGM>.
You are receiving this because you were mentioned.Message ID: ***@***.******@***.***>>
|
Describe the bug
When running the Set-Variables.ps1 script, I get the following error:
PS C:\dev\CodeSamples\TasksTracker.ContainerApps> .\Set-Variables.ps1
At C:\dev\CodeSamples\TasksTracker.ContainerApps\Set-Variables.ps1:74 char:41
"Set $i variable$($i -eq 1 ? '' : 's').
"" | Out-File -F ...Unexpected token '?' in expression or statement.
At C:\dev\CodeSamples\TasksTracker.ContainerApps\Set-Variables.ps1:76 char:43
nWrote $i variable$($i -eq 1 ? '' : 's') to $file.
n"Unexpected token '?' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
I am not particularly familiar with PowerShell, but I have tried to adjust the quotes, etc. in those commands, but to no avail. Would you mind offering me some guidance please?
Expected behavior
From the workshop instructions: "Execute the script. You will do this repeatedly throughout the modules. The output of the script will inform you how many variables are written out."
Actual behavior
As per the description:
At C:\dev\CodeSamples\TasksTracker.ContainerApps\Set-Variables.ps1:74 char:41
"Set $i variable$($i -eq 1 ? '' : 's').
"" | Out-File -F ...Unexpected token '?' in expression or statement.
At C:\dev\CodeSamples\TasksTracker.ContainerApps\Set-Variables.ps1:76 char:43
nWrote $i variable$($i -eq 1 ? '' : 's') to $file.
n"Unexpected token '?' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : UnexpectedToken
Reproduction Steps
Just run the script in the latest (or any I think) version of PowerShell.
The text was updated successfully, but these errors were encountered: