I have a powershell script that runs and compiles within the powershell ISE. However, I need to compress it into an .exe so that the users that will use my application can open it easily. To do this I have found that I should use either primalcript or primalforms. The problem is that when I try to run the script, certain cmdlets output error messages on either of these two programs.
For example the line:
$freeRam = Get-CimInstance -ClassName win32_operatingsystem |
Select-Object -expand FreePhysicalMemory
Returns this in PrimalScript:
ERROR: Get-CimInstance : The term 'Get-CimInstance' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again At C:\Users\sieredzkian\Desktop\New folder\User_Launched_Application_3.ps1:166 char:31 + $freeRam = Get-CimInstance <<<< -ClassName win32_operatingsystem | Select-Object -expand FreePhysicalMemory + CategoryInfo : ObjectNotFound: (Get-CimInstance:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException
Whereas in powershell it runs...
Why can it not find the cmdlets? It also does this for a few other cmdlets like Out-GridView
EDIT: My original problem was caused by using primalscript 2011 where only powershell V2 was supported. I was able to fix this by installing the trial version of primalscript 2016. This enabled me to have powershell V3 like I was using in the ISE.