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
Import-Module : The specified module 'StartLayout' was not loaded because no valid module file was found in any module
directory.
At line:1 char:1
+ Import-Module StartLayout;$ToastHeader = New-BTHeader -Title 'Plannin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (StartLayout:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Get-StartApps : The term 'Get-StartApps' 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 line:1 char:225
+ ... \Databases\icons\agenda-153555_640.png' -AppId (Get-StartApps | Where ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-StartApps:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
CreateObject("WScript.Shell").Run "powershell -executionpolicy RemoteSigned -noprofile -command ""Install-Module StartLayout; Install-Module StartLayout ; Get-StartApps | Where-Object name -eq 'Notepad';Start-Sleep -Seconds 8;""", 1, True
- Feb 10, 2024but then that requires Admin rights, so that's a no go.
Really odd, that it works fine in the ISE, but not run from cmd...- LainRobertsonFeb 10, 2024Silver Contributor
I have zero experience with Office automation - that's totally not my area, so forgive my ignorance on that front.
However, the only reason a module would not be found is if the search path environment variable does not contain a match, which in this scenario is odd since it's a module that ships with Windows itself.
I've had a strong aversion to anything "per user" for 24-odd years now (courtesy of wearing an application packaging hat many years ago) meaning all my modules are installed per machine, which leaves me unable to replicate this issue - not that I potentially could given this is a pre-canned module.
That leaves me unsure on what the issue could be. But, after availing myself on how to put something very basic (no pun intended) together in VBA, I'd be curious to see what the output for these three functions is in your environment:
VBA code in Excel
Function GetPSVersion() Set Process = CreateObject("WScript.Shell").Exec("powershell.exe -Command ""& { [PSCustomObject] $PSVersionTable | Write-Host; }""") Do While Process.Status = 0 Application.Wait (Now() + TimeValue("0:00:01")) Loop GetPSVersion = Process.StdOut.ReadAll End Function Function GetModulePaths() Set Process = CreateObject("WScript.Shell").Exec("powershell.exe -Command ""& { (Get-Module -ListAvailable -Name StartLayout).ModuleBase; }""") Do While Process.Status = 0 Application.Wait (Now() + TimeValue("0:00:01")) Loop GetModulePaths = Process.StdOut.ReadAll End Function Function GetPath() Set Process = CreateObject("WScript.Shell").Exec("powershell.exe -Command ""& { $env:Path.Split(\"";\"", [System.StringSplitOptions]::RemoveEmptyEntries); }""") Do While Process.Status = 0 Application.Wait (Now() + TimeValue("0:00:01")) Loop GetPath = Process.StdOut.ReadAll End FunctionOutput
This is obviously from my own client.
Cheers,
Lain
- Feb 11, 2024
This is what I get returned:
?GetPSVersion
@{PSVersion=5.1.19041.3930; PSEdition=Desktop; PSCompatibleVersions=System.Version[]; BuildVersion=10.0.19041.3930; CLRVersion=4.0.30319.42000; WSManStackVersion=3.0; PSRemotingProtocolVersion=2.3; SerializationVersion=1.1.0.1}
?GetModulePaths
?GetPath
C:\Program Files (x86)\Microsoft Office\Office15\
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\
C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\
C:\Windows\system32
C:\Windows
C:\Windows\System32\Wbem
C:\Windows\System32\WindowsPowerShell\v1.0\
C:\Windows\System32\OpenSSH\
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
C:\Program Files\Intel\WiFi\bin\
C:\Program Files\Common Files\Intel\WirelessCommon\
C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\WINDOWS\System32\OpenSSH\
C:\Users\Daniel\AppData\Local\Microsoft\WindowsAppsSince GetModulePaths() returned nothing via VBA, I ran the command in the ISE and get:
C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\StartLayout
- Feb 10, 2024Could you try Install-Module StartLayout -Scope CurrentUser