Forum Discussion
Get-StartApps : The term 'Get-StartApps' is not recognized as the name of a cmdlet, function, script
- Feb 11, 2024
The only suggestion I have now is replacing your "powershell.exe" statement with a full path alternative of:
C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exeCheers,
Lain
Here's a fourth function to try and some Microsoft documentation you can use to try diagnosing your $env:PSModulePath value.
It seems like under Excel that perhaps the Windows system location (third option from the output below) may be missing, though I cannot begin to fathom why - assuming you're running both the ISE and Excel under the same user account.
But I guess the proof (or contradiction) of that assumption will be in the output from the fourth function.
Fourth Excel function
Function GetPSPath()
Set Process = CreateObject("WScript.Shell").Exec("powershell.exe -Command ""& { $env:PSModulePath.Split(\"";\"", [System.StringSplitOptions]::RemoveEmptyEntries); }""")
Do While Process.Status = 0
Application.Wait (Now() + TimeValue("0:00:01"))
Loop
GetPSPath = Process.StdOut.ReadAll
End Function
Output
Microsoft documentation on search locations
I'm assuming that if you run a "Get-Module -ListAvailable -Name StartLayout" from a Windows PowerShell session, not from the ISE, that it does indeed find the StartLayout module?
Cheers,
Lain
C:\Program Files\WindowsPowerShell\Modules
M:\Documents\WindowsPowerShell\Modules
C:\Program Files (x86)\WindowsPowerShell\Modules
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules
Get-Module -ListAvailable -Name StartLayout
returns nothing in the x86 console, but work in the standard console (x64)
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.0.0.2 StartLayout {Export-StartLayout, Import-StartLayout, Export-StartLayou...
- LainRobertsonFeb 16, 2024Silver Contributor
Fair enough, though it means your functions will only work on 32-bit Office, since the virtual alias of sysnative only exists for 32-bit processes running on 64-bit Windows (with syswow64 being the alias in the opposite direction of 64-bit process requiring a 32-bit Windows resource).
Cheers,
Lain
- Feb 16, 2024Thanks for all your help!
sysnative is the solution. I'm not checking if the OS is 64-bit and then using sysnative is required.. - LainRobertsonFeb 11, 2024Silver Contributor
Above my pay grade again (on the why), but here's some doco on it:
On the how, it's a process-level translation, not a physical construct.
Still, as long as you're working, you're good. And you've got a new trick to leverage should this kind of occurrence arise again.
Cheers,
Lain
- Feb 11, 2024
Just got that working.
c:\windows\sysnative\WindowsPowerShell\v1.0\powershell.exe
does launch PS x64.
But why????
C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe does not exist.
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe exists and tried that but it still launches PS x32
Where does SysNative come from???? I found it in a discussion, but why wouldn't the real path 'System32' work?Why does MS do screwy things like this! If I give the path to the exe I want t you, why would MS override that!
- LainRobertsonFeb 11, 2024Silver Contributor
The only suggestion I have now is replacing your "powershell.exe" statement with a full path alternative of:
C:\Windows\SysNative\WindowsPowerShell\v1.0\powershell.exeCheers,
Lain
- LainRobertsonFeb 11, 2024Silver Contributor
"Furthermore, why wouldn't all CmdLets not be available in both 32 and 64 bitness."
Dunno - above my pay grade.
Cheers,
Lain
- LainRobertsonFeb 11, 2024Silver Contributor
A fifth (and final) function to quickly check if the instance of Windows PowerShell being launched by Excel is 32-bit (False) or 64-bit (True).
Fifth function (for is64Bit)
Function GetIs64Bit() Set Process = CreateObject("WScript.Shell").Exec("powershell.exe -Command ""& { [System.Environment]::Is64BitProcess; }""") Do While Process.Status = 0 Application.Wait (Now() + TimeValue("0:00:01")) Loop GetIs64Bit = Process.StdOut.ReadAll End FunctionOutput
Cheers,
Lain
- Feb 11, 2024Yes, I'm running Office x86 on Windows 10 x64
- Feb 11, 2024So it's a console bitness issue it would see.
But what I don't get is even when I explicitly call
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
testing
[Environment]::Is64BitProcess
returns false???
Furthermore, why wouldn't all CmdLets not be available in both 32 and 64 bitness. - LainRobertsonFeb 11, 2024Silver Contributor
Okay, so that's an interesting observation.
I never use the Windows PowerShell x86 console, but in checking it now, the StartLayout module is indeed not available, meaning it's only available as x64.
Are you running x32 Office rather than x64?
FWIW, I'm running x64.
Cheers,
Lain