Jump to content

Recommended Posts

Posted

I am wondering if it is possible from my scripts to write to the logs that are linked in the Scripts tab. There is some output on a few of my existing scripts but mostly nothing but a time stamp in the log.

I tried Write-Output with no success.

Posted

You can do some logging with write-output, the problem is I havent found a way to do formatting. The usual tricks of trying things like `r`n etc.. didnt seem to work.

image.png.186a90441beb5aa507198d75129dacbf.png

 

The second line is something I'm outputting. I do have more complex examples, but I'd have to spend half the day blurring out anything my employer might not be happy with me sharing 🤣

You will have to experiment a bit, YMMV on how much gets captured. The ones that tend to work for me are the ones where I append to a variable then write-output that variable at the end.

You could also try this: Log Smuggler – WSNONE if you really want to get logs out. Its an assumption this still works. And its not supported by Omnissa in anyway. 

  • Like 1
Posted (edited)

I generally implement a -log option in my scripts, or hard code it where arguments cannot be passed which triggers a Start-Transcript at the start of the script either to the same file with -append or to a date/time specific file/folder with a Stop-Transcript at the end (or in the finally block of a try/catch).

Another way is to enable PowerShell transcription which can be done via GPO but it's just registry values so I tend to do it on the fly as you need to watch disk space if it's permanently on. The small downside is that the file names produced are random but it contains all output and error details.

https://x.com/guyrleech/status/1179144340838502400

 

Edited by Guy Leech
Link not working

Regards,

Guy

@guyrleech

Posted
On 11/27/2024 at 8:13 PM, Phillip Helmling said:

Hi @Matthew Slatosky no it is not really at this time, but a great feature request! I assume you would only write when there is a failure as returning info is what sensors is for and that does display in the Device Details > Sensors tab

Yes, something simple for a sanity check.

  • Like 1
Posted

I typically use my own logging function that writes logs in the Hub log location. This way you can easily obtain your script logs by requesting Hub logs in the UEM console 🙂

 

#=============================================================
# Parameters
#=============================================================
$logpath = "C:\ProgramData\AirWatch\UnifiedAgent\Logs"
$logfile = "C:\ProgramData\AirWatch\UnifiedAgent\Logs\onboarding.log"

#=============================================================
# Create Log Path
#=============================================================
if(-not (Test-Path $logpath)){
    New-Item -ItemType Directory -Path $logpath -Force
}
function Write-Log {
    param($msg)
    "$(Get-Date -Format G) - Onboarding $msg" | Out-File -FilePath $logfile -Append -Force
}

#=============================================================
# Script commands start here
#=============================================================
Write-Log " - Power Settings: Starting script to modify power settings"

  • Like 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...