Hi, from time to time I receive some alerts from sql related web sites which talk about executing sql code in powersehll and as I have PS 7 on my box, I go ahread and fire terminal which uses PS 7 in which code does not execute but when I switch to standard/old PS code works fine. This morning I was reading “Calling Procs from PowerShell with Parameters” at Calling Procs from PowerShell with Parameters – SQLServerCentral
in PS7 code just dont work as follows
11 | $p1 = $cmd.Parameters.Add(‘@StartProductID’,[int])
| Cannot find an overload for “Add” and the argument count: “2”.
13 | $p1.Value = 749
| The property ‘Value’ cannot be found on this object. Verify that the property exists and can be set.
Welcome to the forum.
Windows PowerShell and PowerShell Core are based on different versions of the dotNet Framework. If the code you want to run depends on specific methods only available in a particular version of the framework you cannot run this code on a framework not having these methods.
Thanks Olaf, again another confusion by MS, why not replicate what is in PS standard in PS 7. Hving same name for the same platform with different verion number is a huge ssource for confusion and that way we need to have both as things are missing in each version. I use heavily Azure Devops server pipeline and encountered a lot of issues with PS scripts. I open a ticket with TFS community, somethimes they indicate to switch to PS7 somethimes to PS !!!
Sometimes you have to cut off old habits when you want to go forward and change from a closed source Windows only technology to an open source solution made for almost all major system architectures.
But since you can install PowerShell core on older systems as well you’d be probably better off with switching to PowerShell core if possible.
OK thanks but still if MS can incorporate all exisiting functions in the new global core PS would be great
MS doesn’t care about PowerShell Desktop edition and neither should anyone else, you should use Core edition for everything, and if someone suggests you to use Desktop edition they’re wrong as simple as that.
Anything that runs in PS Desktop can run in PS Core as well.
There are certain methods and OS specific things which don’t run in PS Core, but you can make them run by using the so called “Compatibility” module which will soon become a standard in PS Core and there won’t be any need to install it separatelly.
Those commandless witch don’t work in Core will soon have a parameter
-UseWindowsPowerShell, some already do, it’s only a matter of time until all OS specific commandlets will implement this param.
Until then you can get compatibility module for Core here:
It’s actually not that confusing. What people call PS core (actually out of date name, it’s just PowerShell now) is the future. It is not OS specific and is based on the open-source version of Dot Net.
Windows PowerShell 5.1 is not open source and not based on an open-source version of Dot Net. It is best thought of as depreciated and in a long slow march to out of support/date etc.
So many thanks for the explanations. This exactly what I understood 2 years bak and that is why I have PS 7 setup and even configured my Teminal to use PS7 but as I said that I was surprised with so many functions not running in PS7. I understand better now.