Hello, I am new to Automox and trying to figure out how custom worklets work. We are working on deploying a new print solution and wanting to remove printers that were installed via our print servers via powershell. Below is my worklet:
Evaluation Script:
<#
.SYNOPSIS
This Evaluation code throws and exit as 1 so the script will run no matter what. This is needed as Automox remediation code will run on any exit code greather than 0. If the exit code is 0, then the evaulation code will be skipped
#>
Exit 1
Remediation Script:
start-transcript C:\windows\temp\worklet-transcript.txt
$scriptBlock = {
Get-Printer | Where-Object {$_.ComputerName -eq "ServerName01"} | Remove-Printer
Get-Printer | Where-Object {$_.ComputerName -eq "ServerName02"} | Remove-Printer
Get-Printer | Where-Object {$_.ComputerName -eq "ServerName03"} | Remove-Printer
}
$exitCode = & "$env:SystemRoot\sysnative\WindowsPowerShell\v1.0\powershell.exe" -ExecutionPolicy Bypass -WindowStyle Hidden -NoProfile -NonInteractive -Command $scriptBlock
stop-transcript
I feel that I am missing something as I know the worklet seems to run as it generates the transcript ona the client. However it does not remove the printers. I know when ran manually on user machines, it must be ran in the user context(non admin powershell) since they are installed on the users profile. I guess what I am more concerned with is that the worklet is not setup correctly or something like that.
Thanks.