Welcome to OCS Inventory NG community support, where you can ask questions and receive answers from other members of the community.

Please ask questions only in English or French.

Release 2.5 available

The official documentation can be found on http://wiki.ocsinventory-ng.org. Read it before asking your question.

Windows Agent with Powershell custom plugins [closed]

Dear Community,

I have to deploy a Windows Agent 2.4.0 with a Powershell plugin packed in it. The powershell scripts itself works but apparently it's not collecting data and sending it to the server.

I've already enabled the powershell script on the server I want to monitor (https://wiki.ocsinventory-ng.org/08.Extras/Enable-Powershell-Support-on-Windows-Agent/)

Is there some specific command to add to the script?

Thanks a lot for you help.

Kind regards
closed with the note: Problem solved by user
asked in OCS Inventory NG agent for Windows by (1.3k points)
closed by

5 Answers

0 votes
Hi,

Could you explain, please?

Kind regards

Frank
answered by (66.5k points)
0 votes
Hi Frank,

In the log there's the line that tell that the plugin has been executed succesfully: "Plugin <lastupdate.ps1> executed successfully"

But there is no trace of it in the "Inventory informations for computer" nor on the server.

Running it manually it "prints" the output. I was wandering if there are some specific command to use in order to make it "OCS compatible"

This is the script:

function Get-LastUpdate {
    $secfix = (Get-HotFix -Description "Security*" | measure-object -Property Installedon -maximum).maximum
    $LastUpdate = ($secfix).tostring("yyyy-MM-dd HH:mm:ss")
    Write-Output $LastUpdate
}
  
Write-Output "<LASTUPDATE>"
Get-LastUpdate
Write-Output "</LASTUPDATE>"

Kind regards,

Gabriele
answered by (1.3k points)
0 votes
Run this command to create a local inventory file and see if plugin informations are stored in the xml file.
Command to run from C:\Program Files (x86)\OCS Inventory Agent => ocsinventory.exe /xml=C:\Temp
Kind regards

Frank
answered by (66.5k points)
0 votes
Hi Frank,

The problem is how ocs undestand the powershell output

What powershell regularly print as

<LASTUPDATE>

text

</LASTUPDATE>

ocs agent translates this to <LASTUPDATE />

Do you have any suggestion?

Kind regards,

GabrieleT
answered by (1.3k points)
0 votes
Hi Frank,

I've found out what was wrong:

The plugins need a "double TAG" and apparently they work better using "Write-Host"

$LastUpdate = '<LASTUPDATE><TIME>' + $secfix.tostring("yyyy-MM-dd HH:mm:ss") + '</TIME></LASTUPDATE>'
Write-Host $LastUpdate
answered by (1.3k points)
 
Powered by Question2Answer
...