Brew and Powershell Install

Eskobar
Contributor

We have Yubikeys paired keys with MacOS. I have to export Yubikey Cert infos to shared smb.

Solution: I have a Powershell script to deploy on admin and non admin users.

Requirements:

  1.   Brew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2.   Powershell  brew install --cask powershell
  3.  brew install ykman
  4. pws script.ps1

These commands are working just fine locally. Am not able to write these commands using a script  to be deployed as Jamf Policy. Any idea?

1 ACCEPTED SOLUTION

Tribruin
Valued Contributor II

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. 

View solution in original post

4 REPLIES 4

Tribruin
Valued Contributor II

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. 

 

Eskobar
Contributor

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,

Tribruin
Valued Contributor II

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. 

Eskobar
Contributor
Issue fixed 
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 :)