/build/static/layout/Breadcrumb_cap_w.png
09/03/2019 154 views

Hi, 

I have a working Online KACE Script that creates a .CSV logfile of the recent WLAN connections SSID name and connection time.  

It is then parsed out as a Custom Inventory Rule 

ShellCommandTextReturn(powershell -command "if(test-path C:\Logs\RecentWLANConnections.csv) {import-csv C:\Logs\RecentWLANConnections.csv}")

4) CustomInventory.RecentWLANConnections:
SSID TimeCreated
---- -----------
WiFi Name 4/09/2019 10:56:18 AM


This all works fine with the expected results when looking at Inventory > Devices >Particular Device > Custom Inventory Fields but I am unable to select this particular CIR for further Reporting when creating a new report via the Wizard. All other CIRs are available to be selected in the wizard. 

 I want to be able to create a report that then takes that specific CIR and filters the data further based on SSID and User.  

K1000 v9.1.317


PowerShell Kace Online Script below;


#Application Name

$ApplicationName = "RecentWLANConnections"


#Do Not Change These

$LogFilePath = "C:\Logs\"

$LogFile = "$LogFilePath$ApplicationName.csv" 

$OldLogFile = "$LogFilePath$ApplicationName.old.csv"


#-----------------------------

#Create the log file

#-----------------------------


#Write-Host "Do not close this window" -foregroundcolor "Yellow" 


#Check if path exists

if(-not (test-path $LogFilePath)){

    #Create Logs Folder

    new-item $LogFilePath -type directory | out-null

}


#Check if $LogFile exists

if(-not (test-path $LogFile)){ 


    #Create $LogFile

    new-item $LogFile -type file | out-null

    #Log "Log File Created" 

}


#If $logFile exists then re-name it

else{

    

    #Check if $OldLogFile Exists

    if(-not (test-path $OldLogFile)){

         rename-item $LogFile $OldLogFile

    }

    #Remove the previous $OldLogFile

    else{

        remove-item $OldLogFile

        rename-item $LogFile $OldLogFile        

    }

    #Create $Logfile

    new-item $LogFile -type file | out-null

    #Log "Log File Created"

}


#---------------------

#Log the command we are running

#---------------------

#Function RunCommand ($Command) 

#Log $Command

#Display commands to console.

#write-host $Command 

#Execute

#Invoke-Expression -command $Command | out-null #do not show output

#


#---------------------

#Run the guts of it

#---------------------

#Specify Timeframe to search between 


$StartTimestamp = [datetime]'09:00:00'

$EndTimeStamp = [datetime]'15:00:00' 


$Filter = {($_.TimeCreated -gt $StartTimestamp) -and ($_.TimeCreated -lt $EndTimeStamp)} 


$Events = Get-Winevent -FilterHashtable @{Logname='Microsoft-Windows-WLAN-AutoConfig/Operational';Id=8000} -MaxEvents 10 | Where $Filter 


ForEach ($Event in $Events){

$eventXML = [xml]$Event.ToXml()

For ($i=0; $i -lt $eventXML.Event.EventData.Data.Count; $i++){              

            # Append these as object properties            

            Add-Member -InputObject $Event -MemberType NoteProperty -Force -Name $eventXML.Event.EventData.Data[$i].name -Value $eventXML.Event.EventData.Data[$i].'#text'            

                   }

           }


$Data = $Events | Select-Object SSID, TimeCreated | Export-Csv $LogFile

2 Comments   [ + ] Show comments

Comments

  • I would connect to the KACE SDA Database Using:

    https://support.quest.com/kb/114992/can-i-access-the-k1000-appliance-database-using-a-third-party-reporting-tool-

    If your Custom Inventory Rule is NOT populating anything in the Database, the reporting module will not work for this scenario.
  • Do you have a lot of custom inventory rules? You can create the report with the wizard and select a visible field. Then convert the report to sql, and replace the software ID.

All Answers

2

Could be there is no return so no text to write. 

When you run the powershell script on a machine do you get any return?

Use a my sql tool and attach to the kbox. You can see if that field is null or has a blank entry in it ( it may be writing just a empty string to the field when it runs)

Answered 09/04/2019 by: SMal.tmcc
Red Belt

  • Definitely getting returns, Im more just wondering why a CIR wouldnt show up in the Reporting new report wizard.

    An example from a Inventoried Device,

    CustomInventory.RecentWLANConnections:
    SSID TimeCreated
    ---- -----------
    iDET 4/09/2019 12:17:48 PM
    • Try changing your CIR to

      ShellCommandTextReturn(cmd /c powershell -command "if(test-path C:\Logs\RecentWLANConnections.csv) {import-csv C:\Logs\RecentWLANConnections.csv}")

      It is weird that it shows in the detail page but not as a wizard field choice. On your wizard report did you use "Device" as topic?

      You might also try renaming the CIR software entry name, run inventory a couple of times on a machine to see if that fixes it.

      If that does not work I will load this on my kbox as cir and see if it does same thing.
      • Thanks SMal.tmcc! That CIR change resolved the issue! I'll have to be more aware of how I call the powershell module in future!
        Really appreciate the guidance!

        Cheers mate.