TRIGGERcmd
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    PS scripts do not work, CommandNotFoundException

    Windows
    powershell windows problem
    2
    3
    513
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • TX NerdT
      TX Nerd
      last edited by TX Nerd

      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?

      RussR 1 Reply Last reply Reply Quote 0
      • RussR
        Russ @TX Nerd
        last edited by Russ

        @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
        }
        

        Russell VanderMey

        TX NerdT 1 Reply Last reply Reply Quote 0
        • TX NerdT
          TX Nerd @Russ
          last edited by

          @Russ That works, thank you!

          1 Reply Last reply Reply Quote 1
          • First post
            Last post