Tyler Melville Posted April 19 Share Posted April 19 Up until the most recent update to Pulseway, I was able to install the Huntress agent via their provided Powershell script at: https://github.com/huntresslabs/deployment-scripts/blob/main/Powershell/InstallHuntress.powershellv2.ps1 This script includes the "param" command, which has to be the first line of the script in order to run. After the recent update to Pulseway, all scripts that are run add an $ENV_AgentTemp variable to the top of the script, see screenshot below: This prevents the script from running correctly, see screenshot below of the error: Please note that the powershell output shows the error on line 32, whereas in the script it is on line 31, which is what led me on the path to find that the extra line was being added at the top of the script by Pulseway. Is there a way to prevent that first line from being added to the script, or do I need to contact Huntress and have them rework a different version of the script that doesn't include the "param" command? Cheers. Link to comment Share on other sites More sharing options...
Brandonn Posted April 21 Share Posted April 21 (edited) You are using parameters outside of a function. Parameters can only be defined inside of a function, otherwise you are essentially trying to run the 'param' command. For example: Edited May 2 by Brandonn Photos did not come through Link to comment Share on other sites More sharing options...
Richard Davis Posted April 25 Share Posted April 25 On 4/22/2023 at 12:57 AM, Brandonn said: You are using parameters outside of a function. Parameters can only be defined inside of a function, otherwise you are essentially trying to run the 'param' command. For example: Hi. Can you repost your images I can not see them. Thanks, Richard Link to comment Share on other sites More sharing options...
Richard Davis Posted April 25 Share Posted April 25 I have the same issue, I have found the script works fine deployed via Pulseway on Windows 10 but fails on Windows 11. The script works fine when run locally in PowerShell on both OS. Link to comment Share on other sites More sharing options...
Tyler Melville Posted April 26 Author Share Posted April 26 Hi Richard, The screenshots are below. Please let me know if you have issues with it showing. This is happening with both Windows 10 and 11 devices. Link to comment Share on other sites More sharing options...
Brandonn Posted May 2 Share Posted May 2 (edited) On 4/25/2023 at 11:12 AM, Richard Davis said: Hi. Can you repost your images I can not see them. Thanks, Richard They should be there now. Maybe wrap the huntress install script in a function that passes all the relevant information? I did some more testing, and you can include the arguments if you are just running the script normally, but since you cannot include additional arguments when running the script through Pulseway, they will have to be manually added to the script. I believe this would work. function Install-Huntress { param ( [string]$acctkey, [string]$orgkey, [string]$tags, [switch]$reregister, [switch]$reinstall, [switch]$uninstall, [switch]$repair ) # Rest of the code return "$acctkey - $orgkey - $tags - $reregister - $reinstall - $uninstall - $repair" } Install-Huntress -acctkey 1234 -orgkey 5678 -tags "tag1" -reregister $true -uninstall $false -repair $false Edited May 2 by Brandonn Fixed Script Link to comment Share on other sites More sharing options...
Tyler Melville Posted May 10 Author Share Posted May 10 Thanks for your help, Brandonn. This has resolved the issue. I have been in touch with Huntress support and they are creating a Pulseway-specific installer script using the solution you provided above. Cheers. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now