Why doesn't my Skript get executed via Policy?

UndercoverMaik
New Contributor

Hey,

I am trying to run a "Mac-Renaming" Skript via Policy, but it shows me something like this in the policy log:

 
UndercoverMaik_1-1648030205251.png

 

 

if i run the skript on the mac itself it works just fine, but as soon as I try to deploy it via Policy i get this error.

here is the Skript:

#!bash/sh

arr=( $(ls /users) )

str=${arr[@]:3}

year=$(date +%Y)-

lengthUsername=${#str}

substr="${str:2:$lengthUsername}"

sudo /usr/local/bin/jamf setcomputername -name "$year$substr"

sudo /usr/local/bin/jamf recon

 

can someone help me to find the issue?

2 REPLIES 2

Bol
Valued Contributor

Change this line;

#!bash/sh

To;

#!/bin/sh

DBrowning
Valued Contributor II

I'd try changing #!bash/sh to either #!/bin/bash or #!/bin/sh