Community FAQ
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
deanmcclymont77
Engaged Sweeper

Hi Guys,

 

Currently in the middle of trying to roll out LS to our estate of Macs via Intune, does anyone know the best way because I cant seem to find a decent script to push it out or when its uploaded as a line of business app. 

 

I need to be able to have the parameters of server, port and cloud relay key too.

 

Any help would be appreciated. 

10 REPLIES 10
kv-jsmith
Engaged Sweeper III

Hope this helps! It works fine in our environment.

Home > Devices | MacOS > macOS | Scripts > LsAgent

Basics

Name                                                               LS Agent
Description                                                      LsAgent is Lansweeper's agent-based scanning method designed for scanning                                                                            hard-to-reach devices or machines which have strict network security protocols.
Settings

Shell script                                                       installLsAgent.zsh

**Replace agentkey and server on Line 31 with values for your installation**
                     

Spoiler
#!/bin/zsh
#set -x

# disk image
 
fileURL="https://content.lansweeper.com/lsagent-mac/"

# Specify name of downloaded disk image

LsAgent_dmg="/tmp/LsAgent-osx.dmg"

# Download the latest LSAgent software disk image

	/usr/bin/curl -L --output "$LsAgent_dmg" "$fileURL"

    # Specify a /tmp/LsAgent mountpoint for the disk image
 
    TMPMOUNT=`/usr/bin/mktemp -d /tmp/LsAgent`

    # Mount the latest LsAgent disk image to /tmp/LsAgent mountpoint
 
    hdiutil attach "$LsAgent_dmg" -mountpoint "$TMPMOUNT" -nobrowse -noverify -noautoopen
    


	# Install LsAgent from the installer package stored inside the disk image
    # agentkey is the Relay Authentication Key - Scanning > Relay Configuration
    # server is the dns name you registered for your site or the ip with no http or 
    # https in the beginning

	"/tmp/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh" --server SITEURL --port 9524 --agentkey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx --prefix /usr/local/LsAgent --mode unattended
	
    sleep 30
	
    # Clean-up
 
    # Unmount the LsAgent disk image from /tmp/LsAgent
 
    /usr/bin/hdiutil detach "$TMPMOUNT"
 
    # Remove the /tmp/LsAgent mountpoint
 
    /bin/rm -rf "$TMPMOUNT"

    # Remove the downloaded disk image

    /bin/rm -rf "$LsAgent_dmg"
    
    exit 0

Run script as signed-in user                            No
Hide script notifications on devices                Not configured
Script frequency                                              Not configured
Max number of times to retry if script fails     3 times

Scope tags
  Default

Assignments

Included groups                                               All Devices

Excluded groups                                              No Excluded groups

 

ErikT
Lansweeper Tech Support
Lansweeper Tech Support

Hi @deanmcclymont77 

 

I assume you are refering to installng LS agent to a Mac device here. Please check out the below article. It will explain how to silently install LsAgent to a Mac device. There also is a section that explains the parameters required.


https://community.lansweeper.com/t5/scanning-your-network/silently-installing-lsagent-on-a-windows-l...
 

DSC
Engaged Sweeper

Hello ErikT,

we discovered the same problem as mentioned above.

The skript in your documentation for the silent installation wont work and i dont know why.

Even if i only deploy the lansweeper "lsagent-osx.dmg" manually without intune, i cant run this command:

LsAgent-osx.app/Contents/MacOS/installbuilder.sh --server xxx --port xxx --agentkey xxx --mode unattended

There is always an error "no such file or directory".

Is there any solution?

Perfect case would be deploying the .pkg via intune and automatically run the skript to register the device.

Thanks in advance

Hello,

 

I used this script within Intune in the end, and it worked perfectly. Hope it helps

!/bin/bash

# --- Configuration ---
AGENT_URL="https://content.lansweeper.com/lsagent-mac/" # Replace with the latest LsAgent URL
AGENT_DMG="/tmp/LsAgent-osx.dmg"
AGENT_MOUNTPOINT="/Volumes/LsAgent"
INSTALL_SCRIPT="/Volumes/LsAgent/LsAgent-osx.app/Contents/MacOS/installbuilder.sh"
SERVER_ADDRESS="" # Replace with your Lansweeper server address
SERVER_PORT="9524" # Replace with your Lansweeper server port
AGENT_KEY="" # Replace with your Lansweeper agent key

# --- Download and Mount ---
echo "Downloading LsAgent..."
curl -L "$AGENT_URL" -o "$AGENT_DMG"

echo "Mounting LsAgent DMG..."
hdiutil attach "$AGENT_DMG" -mountpoint "$AGENT_MOUNTPOINT" -nobrowse

# --- Install ---
echo "Running LsAgent installer..."
sudo bash "$INSTALL_SCRIPT" --server "$SERVER_ADDRESS" --port "$SERVER_PORT" --agentkey "$AGENT_KEY" --mode unattended

# --- Cleanup ---
echo "Unmounting LsAgent DMG..."
hdiutil detach "$AGENT_MOUNTPOINT"
rm -f "$AGENT_DMG"

echo "Installation complete."

Can you tell me how did u deploy the script?

I tried it and it works partly.

The mounting works flawless and i can see the drive agent.dmg mounted under "/tmp/" but thats all. The Installation won't finish.

Even if i execute the script locally on the macos there are errors.

Any ideas?

 

DSC
Engaged Sweeper

nb-mbpro16-03:Downloads mgm$ sh lsAgent.zsh

: command not found:

: command not found1:

Downloading LsAgent...

curl: (3) URL rejected: Malformed input to a URL function

: command not found5:

Mounting LsAgent DMG...

hdiutil: attach: unknown option "-nobrowse\r"

Usage:  hdiutil attach [options] <image>

  hdiutil attach -help

: command not found8:

Running LsAgent installer...

: No such file or directoryent-osx.app/Contents/MacOS/installbuilder.sh

: command not found2:

Unmounting LsAgent DMG...

hdiutil: detach failed - Es existiert keine Datei und kein Ordner dieser Art

: command not found7:

Installation complete.

kv-jsmith
Engaged Sweeper III

Did you try mine up a above? I outlined everything in Intune that you'd configure, and the script is in the spoiler block.

https://community.lansweeper.com/t5/deployment-packages/installing-ls-for-mac-via-intune/m-p/81198/h...

DSC
Engaged Sweeper

Also got errors but i figured out what i did wrong.

Already testing right now but synchronizing from intune is taking a bit too long 🙂

kv-jsmith
Engaged Sweeper III

Haha, I understand the struggle of Intune sync issues:-(. If you have remote access to machines there are ways of forcing a quicker check in on the machine.

Deployment Packages

Share topics/ issues related to deployment packages. Please use/rely on content with caution as it is publicly generated.

New to Lansweeper?

Try Lansweeper For Free

Experience Lansweeper with your own data.
Sign up now for a 14-day free trial.

Try Now