C
C#2y ago
Decabytes

❔ Trouble Creating PowerShell Commandlet

I'm using visual studio 2022, dotnet 6.0. I installed the automation package using
NuGet\Install-Package Microsoft.PowerShell.SDK -Version 7.2.9
But when I try to import the module after building the package I get the error in the screenshot. Does anyone have any ideas?
3 Replies
jcotton42
jcotton422y ago
@Decabytes what version of PowerShell is that? per $PSVersionTable I have a feeling you're using Windows PowerShell (5.1) and not PowerShell 7
Decabytes
DecabytesOP2y ago
You're right. I was using Powershell 5.1. To fix this I had to
winget install -e --id Microsoft.PowerShell -v 7.2.9.0
winget install -e --id Microsoft.PowerShell -v 7.2.9.0
Then I had to go click the gear in the powershell window of visual studio and add the path to the 7.2.9 version of powershell. Then it worked!
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server