Homebrew needs to be installed within the user context and Jamf runs scripts under the root. You could try running each of those commands as the user in your script. (See this excellent article. Running a Command as another User – Scripting OS X)
With that being said, I would NOT recommend this approach of using Homebrew to install other packages. Instead i would look at installing PowerShell via a package. It looks like Microsoft provides and installation package that should work better. It looks like Yubi also provides a package installer for ykman. You should be able to upload both packages to Jamf and create a policy to install them.
Hello @Tribruin
You're right. I can run the powershell script using without need to use Brew.
Meanwhile, i don't know how to push my script on machines !! any idea ?
Shall i upload the ps1 file to machines than run it or else?
yours,
You should just be able to create a package (using Composer or Packages, my favorite) and install the script where ever it need to be. Make sure your permission are set correctly as well.
1) Packaging the powserhell script using composer.
2) Deploying the pkg in an authorized location.
3) Installing powserhell pkg
4) add script payload: starting with "sudo pwsh" to run the script + remove the file + uninstall powershell
I will test "Packages", might be helpful for future need.
Thanks for help. You 'are so handy :)