I needed to make creating software install worklets accessible to non-script savvy people on my team, so I came up with these.
Real simple… change the variables as instructed in the script notes, copy/paste into a worklet and that’s it. This should be quite accessible for even the most n00bish PowerShell users.
Cheers!
##############################################################################
### ~~~ SWEET'S MSI INSTALL SCRIPT TEMPLATE FOR AUTOMOX! ~~~ ###
##############################################################################
### --NOTES-- ###
##############################################################################
### - Set the name of the software ###
### - Set the path to the executable file (where it lives post-install) ###
### - Set the name of the log file ###
### - Copy/Paste into Worklet!! ###
##############################################################################
#################################################################
### ><><><><><>< START EVALUATION CODE!!! ><><><><><>< ###
#################################################################
# VARIABLES LIST
$swname = "INSERT-SW-NAME-HERE" # ex. "Java 8.341 (32-bit)"
$swpath = "INSERT-SW-PATH-HERE" # ex. "C:\Program Files\Java"
$logname = "INSERT-LOG-NAME-HERE" # ex. "OfficeUpgrade.log"
# Create C:\Temp if it doesn't yet exist
New-Item -Path 'C:\Temp' -ItemType Directory -Force -ErrorAction SilentlyContinue
# Start logging
Start-Transcript -Verbose -Path "C:\Temp\$logname"
# Checks to see if AnyConnect is present on the device
$output = Test-Path $swpath
if ($output){
Write-Output "$swname is already installed."
} else {
Write-Output "$swname not present - installer will begin shortly."
}
Stop-Transcript
if ($output){
Exit 0
} else {
Exit 1
}
#################################################################
### ><><><><><>< END EVALUATION CODE!!! ><><><><><>< ###
#################################################################
# COPY ABOVE THIS LINE INTO EVALUATION PANE
#---------------------------------------------------------------#
# COPY BELOW THIS LINE INTO REMEDIATION PANE
#################################################################
### ><><><><><>< START REMEDIATION CODE!! ><><><><><>< ###
#################################################################
# Set Variables!
$swname = "INSERT-SW-NAME-HERE" # ex. "Java 8.341 (32-bit)"
$logname = "INSERT-LOG-NAME-HERE" # ex. "OfficeUpgrade.log"
$arguments = "INSERT-ARGS-HERE" # ex. '/i "MicrosoftEdgeEnterpriseX64.msi" /q' TOP TIP! - You may need to use single quotes at the start/end!!
# Starts logging and appends the existing log file created by the Evaluation code
Start-Transcript -Verbose -Path "C:\Temp\$logname" -Append
Write-Output "Copying install files..."
Copy-Item $swfilename -Destination "C:\Temp" -Verbose
Write-Output "Install files copied to C:\Temp."
Write-Output "Executing install command..."
# Executing installer - DO NOT make your life harder, eliminate spaces in filenames!
Start-Process msiexec.exe -ArgumentList $arguments -Verbose -Wait
Write-Output "$swname install command executed. Please verify that software is installed as needed."
Stop-Transcript
#################################################################
### ><><><><><>< END REMEDIATION CODE!!!! ><><><><><>< ###
#################################################################