Important Notice: On February 29th, this community was put into read-only mode. All existing posts will remain but customers are unable to add new posts or comment on existing. Please feel to join our Community Discord for any questions and discussions.

Powershell Scanner in Scan Profile

Hello!

 

I have a question regarding the usage of Powershell in scan profiles. I've been trying to add a script that checks the free space available for only the C: drive, but I can't seem to get it working. The problem is that once I enter into a dynamic collection and go to set said scanner as a filter, the column selection reads NULL.

Here is the script,

$disk = Get-WmiObject Win32_LogicalDisk -Filter "DeviceID='C:'"
[PSCustomObject]@{
DiskLetter = $disk.DeviceID
FreePercent = [math]::Round(($disk.freespace / 1GB) / ($disk.Size / 1GB) * 100)
FreeSpace = [math]::Round($disk.FreeSpace / 1GB)
DiskSize = [math]::Round($disk.size / 1GB)
}

And here is the error that I receive:

Thanks!

Evan

1

Comments

2 comments
Date Votes
  • You have to run that Scan Profile against a computer and get data back before you can create a Collection. The columns are built dynamically based on the object that the script emits when you run it on a target.

    2
  • That was definitely the case. Thanks!

    0