Forum Discussion
12 Replies
Hey Stuart
After spending some time on it i managed to get some sample scripts and understood exactly what it does and how.
## Active Script ##
$hostname = '##SYSTEM.HOSTNAME##'
$namespace = "root\cimv2"
$query = "SELECT NAME FROM Win32_LogicalDisk"
$output = Get-WmiObject -Namespace $namespace -ComputerName $hostname -Query $query
foreach ($instance in $output) {
$name = $instance.Name
Write-Host "$name##$name"
}
exit
## Collector Script ##
$hostname = '##SYSTEM.HOSTNAME##'
$wildvalue = '##WILDVALUE##'
$namespace = "root\cimv2"
$query = "SELECT * FROM Win32_LogicalDisk WHERE NAME='$wildvalue'"
$output = Get-WmiObject -Namespace $namespace -ComputerName $hostname -Query $query
Write-Host "Size=$($output.Size)"
Write-Host "FreeSpace=$($output.FreeSpace)"
exit
Now i remain with few other questions
1. This is WMI so gets me the partition names, how can i get the paths to iterate in Active script
So I manually Added monitored instances under my resource, but didn't work for me.
2. Tried Setting up UNC.PATH, didn't work
I'll spend time trying few things here n there until I hear back from you.
Please advice
Thank you
- AnonymousOn 5/17/2020 at 1:36 AM, Ashiwad said:
1. This is WMI so gets me the partition names, how can i get the paths to iterate in Active script
So I manually Added monitored instances under my resource, but didn't work for me.
If you have an active discovery script, you won't need to manually add instances. If you want to discover different instances, like folders instead of partition names, you'll need to adjust your query. You might consider pulling from the Win32_Directory class instead of the Win32_LogicalDisk class.
On 5/17/2020 at 1:36 AM, Ashiwad said:2. Tried Setting up UNC.PATH, didn't work
Not sure what you tried to setup here.
From the looks of your script, you could probably do this without a script by using the built in WMI collector. To help you get started, this is how you would set it up to pull free space on each logical drive. I did this so you can compare it to what you already have in your script. To make it for folders, like I said above, you'd need to use the Win32_Directory class instead. I'm not familiar with that class, so you'd have to do a little research.
Related Content
- 5 months ago
- 5 months ago