Skip to content

Instantly share code, notes, and snippets.

@jbaker10
Created December 10, 2018 18:28
Show Gist options
  • Save jbaker10/a6a3cec082cf5623597b2c9d069e5b2b to your computer and use it in GitHub Desktop.
Save jbaker10/a6a3cec082cf5623597b2c9d069e5b2b to your computer and use it in GitHub Desktop.
enroll_in_airwatch.ps1
$url = "https://storage.googleapis.com/getwsone-com-prod/downloads/AirwatchAgent.msi"
$output = "C:\Temp\AirWatchAgent.msi"
"Checking if temp dir exists, creating if not"
$path = "C:\Temp"
if(!(Test-Path -Path $path)){
"Creating temp directory"
New-Item -ItemType directory -Path $path
}
try {
## Download the file and output it to the defined location
"Downloading application"
Invoke-WebRequest -Uri $url -OutFile $output
## Install the newly downloaded file
"Installing application"
Invoke-Command -ScriptBlock { & cmd /c "$output /q ENROLL=Y SERVER= LGName=staging USERNAME= PASSWORD= ASSIGNTOLOGGEDINUSER=N DOWNLOADWSBUNDLE=TRUE /LOG C:\Temp\AirWatchEnrollment.log" }
## Remove the cached installer
"Removing cached installer"
Remove-Item $output
}
catch {
"Unable to successfully download and install the application. Exiting"
exit 1
}
"Successfully installed AirWatch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment