Jump to content

Returning script output into WS1 script console log


BWMerlin

Recommended Posts

I have written a very simple script in PowerShell and pushed it out to our devices via the script feature in WS1.  When I click on a device and go to the script tab and click on the script run history I can see a variety of information that isn't always the most helpful when troubleshooting.

I was wondering what output from scripts gets returned into the WS1 script log in the console?  Is it as simple as using write-out inside my PowerShell script to have data captured via these logs?

Link to comment
Share on other sites

  • Employee

Scripts differ from Sensors in that they do not return a specific value, rather they return an execution status.

The console shows the script status on the device details page based on the execution code as:

  • Executed - Workspace ONE UEM displays this status after the exit code returns a 0.
  • Failed - Workspace ONE UEM displays this status after the exit code returns any value that is not a 0.

The syntax on your script is basically a line calling Exit 0 or Exit 1.

Hope this helps.

  • Like 1
Link to comment
Share on other sites

  • Employee

The script log should contain your write-output. The example output below is from this example script that uninstalls java

$apps = Get-WmiObject -Class Win32_Product | Where-Object {($_.Name -match "Java") -and ($_.vendor -match "oracle")}
$result = ""
if ($apps)
{
   foreach($app in $apps)
   {
      $appName = $app.Name
      $appVendor = $app.vendor
      $result = $result + "Uninstalling $appName by $appVendor |"
      $app.uninstall() | Out-Null
   }
}
else
{
   $result = "Oracle Java not found"
}
Write-Output $result

image.thumb.png.ca0ac7e4eba445f33d9463a3d0184159.png

Link to comment
Share on other sites

  • 2 weeks later...
On 6/8/2024 at 12:41 AM, Glyn Dobson said:

The script log should contain your write-output.

Thanks @Glyn Dobson, so I just want to clarify if I return anything to write-out put it will show in the WS1 console script log? i.e write-out "hello world"

Link to comment
Share on other sites

  • Employee

Yes, that said I believe the script execution result and the logs are collected separately. Try doing a Workflow sync from the console and see if that causes the logs to be populated. You can also check the troubleshooting tab to see if there were any errors during the execution (timeout etc).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...