Forum Discussion
Anonymous
6 months agoCreate a batchscript datasource using active discovery.
Make the appliesto:
pathtofiles
Use the wildvalue as the unique identifier.
Use this as both the collection and discovery scripts:
$hostname = '##SYSTEM.HOSTNAME##'
$pathToFiles = '##pathtofiles##'
Invoke-Command -ComputerName $hostname -ScriptBlock {
$files = Get-ChildItem -Path $pathToFiles -File -Filter '*.bak'
foreach ($file in $files){
$wildvalue = $file.Name
$age = [math]::Round((Get-Date).Subtract($file.CreationTime).TotalHours, 2)
# For discovery
Write-Host "$wildvalue##$wildvalue"
# For collection
Write-Host "$wildvalue.age: $age"
}
}
Exit 0
Change the filter on line 5 if you want to look at other files.
Make your datapoint called age, use key-value pair, with the key being
##WILDVALUE##.age
Set a property on your device (or group of devices) called pathtofiles where the value is the path to the files you want to include.
Related Content
- 18 days ago
- 8 months ago
- 11 months ago
- 3 months ago