PS scripts do not work, CommandNotFoundException
-
I'm trying to write a script to automatically download the latest iOS/iPadOS IPSWs using blacktop/IPSW. When I run the script from right click>Run or from Powershell-ISE it works fine, but when I execute the script from TRIGGERcmd it pops an error:
==DEBUG: running as John Doe ==DEBUG: working in D:\3uTools\Firmware\IPSWs== Received ipsw.me update notification, downloading new iOS and iPadOS versions ipsw : The term 'ipsw' 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:6 char:1 + ipsw download ipsw --latest + ~~~~ + CategoryInfo : ObjectNotFound: (ipsw:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Script complete, press any key to exit
When run from the .ps1 file directly, or from Powershell-ISE, or from a PS terminal, the script works correctly:
==DEBUG: running as John Doe ==DEBUG: working in D:\3uTools\Firmware\IPSWs== Received ipsw.me update notification, downloading new iOS and iPadOS versions Using config file: C:\Users\John Doe\.ipsw\config.yml • Latest release found is: 16.3.2 ⨯ no IPSWs match device(s) iPhone iPad Script complete, press any key to exit
(the script currently downloads nothing because there is no 16.3.2 for iOS/iPadOS, but that isn't a problem - the command is working as expected)
I've checked that there are no spaces in any directories, I've tried adding a cd to make 100% sure that it's operating in the correct directory, I've added debugs to verify that it's running in the right folder and as a valid user, nothing seems to work.
Here's the script in question:
start powershell { cd "D:\3uTools\Firmware\IPSWs" Write-Host "==DEBUG: running as $env:UserName" #debug to see if TRIGGERcmd is working as a different user Write-Host "==DEBUG: working in $pwd==" #debug to see if TRIGGERcmd is working in a different path Write-Host "Received ipsw.me update notification`, downloading new iOS and iPadOS versions" -ForegroundColor white -BackgroundColor DarkGreen ipsw download ipsw --latest Write-Host "Script complete`, press any key to exit" -ForegroundColor white -BackgroundColor DarkGreen cmd /c pause | out-null }
And here's the TRIGGERcmd command:
{ "trigger": "ipsw.me update announcement", "command": "powershell -file \"D:\\3uTools\\Firmware\\IPSWs\\ipsw_update.ps1\"", "ground": "foreground" }
Thoughts?
-
@TX-Nerd, I think the problem is the scoop\shims folder in your home directory isn't in your PATH. You could add it to your PATH variable, or work around it by specifying the path to ipsw like this:
start powershell { cd "D:\3uTools\Firmware\IPSWs" Write-Host "==DEBUG: running as $env:UserName" #debug to see if TRIGGERcmd is working as a different user Write-Host "==DEBUG: working in $pwd==" #debug to see if TRIGGERcmd is working in a different path Write-Host "Received ipsw.me update notification`, downloading new iOS and iPadOS versions" -ForegroundColor white -BackgroundColor DarkGreen . $home\scoop\shims\ipsw download ipsw --latest Write-Host "Script complete`, press any key to exit" -ForegroundColor white -BackgroundColor DarkGreen cmd /c pause | out-null }
-
@Russ That works, thank you!