Anyone have a solution or idea how one would display the output of the following powershell command in a table?
get-smbshare | Where-Object { $_.Special -eq 0 } | select Name, Path, ShareState, CurrentUsers
Assuming you want table to show up in Solarwinds Web Console and that you are mostly interested in CurrentUsers.
One possibility is you'd need to figure out how to capture this information to the Solarwinds DB so that it can be queried. That "could" be done with SAM via application monitor running powershell Component Monitor where you'd run your powershell script and return result. Problem is it is difficult (and maybe imposible) to return multiple results like the entries in your table above. Assuming that could be figured out, then the result could be queried from DB or using SWIS/SWQL with the result displayed in a table in the web console. The tricky part here is how to return variable number of records via app monitor.
Another issue is that mounted smb shares are per user. When the app monitor is run (or "polled") by Solarwinds, it will not have these shares mounted. Even if the app monitor is run as a user that has SMB share mounted. There might ways around this using local policy, but that might only be limited to a few shares at most.
Assuming you have a list of SMB shares you wish to monitor and the list is known, you could mount each share in a powershell script and then run your script above and process the result which in theory would be the mount you just created. You'd then unmount when the powershell script finishes. Create a app monitor for each share using same template and passing share path as argument. Each instance of the app monitor would report on one SMB share. I'm doing something similar to monitor lots of different log locations on various SMB shares. It is doable but a bit complicated with lots of edge cases to deal with like failed mounts. Plus by doing this you'd be adding one to CurrentUsers...the app monitor itself.
Hope something here sets you down a path to success, and maybe encourages someone else to share some other possible solutions.
"Another issue is that mounted smb shares are per user." not sure what you mean, I the case about the SMB share WWWroot is the UNC share name \\SomeServer\WWWroot, with the Path being the physical location for the folder on the SomeServer example. Using the above as the example again the \\SomeServer\WWWroot SMB share in on the C: Drive with a physical path of C:\Inetpub\WWWroot. As the share is a fixed Network share that any user can see, but limited access thru Windows Rights.
OK yes if all the shares you care about are shared on the workstation you wish to monitor then you are ok. I thought some of your paths might be from remote shares...my bad. Also just realized get-smbshare is for local shares...I had Get-SmbConnection on the brain...
Do you actually need to know the CurrentUsers? if you didn't then I'd suggest the least painful way to deal with this would be using SCM. You could create a custom profile that just dumps this whole table into Orion every 5m or so and then just notify you when the contents change.
If you don't have SCM, or want to stick to SAM then things are going to get a lot harder. The limitation is that SAM doesn't ingest whole tables of data. It is designed so that it normally only ingests a single value at a time. You can get slightly more complex and get it to take up to 10 values, but there is no built in way to take in and display more rows of data than 10 in a SAM component.
I have done a work around, but its a little complex so it is only suitable if you are really comfortable with the SW API. It's actually pretty similar to what @bucweat suggested to do, except in my case i was using the API to automate it because doing it by hand wasn't going to scale for what I needed. There's a lot of extra detail I'm leaving out because I don't want to make the explanation too complicated, but the gist of it is as follows:
I'd have a template where the first component (call it component A) would basically just get me the list of all the rows in the table, so working with something like this to populate the message of my script component.(get-smbshare | Where-Object { $_.Special -eq 0 } | select Name) -join ","
Then I would have a second component (component in the template that was disabled that would be an example of how I would make a component for just a single item in the list, so in this case it would be something like
get-smbshare | Where-Object { $_.Special -eq 0 -and $_.Name -eq "placeholder" } | Name, Path, ShareState, CurrentUsers
The last step would be to have a script that just parsed the message string from component A and then reach into the SAM database tables and for each row of the table it would make a copy of component B and replace the "placeholder" string with the correct filter for each row of the table, and set the component be enabled. So I deploy the template, initially it just gets all the rows, then when this second part kicks in it just automatically created any number of additional components on each server where I'd be running the template.
That last step could be part of the same template, but I didn't want mine to be running every 5 minutes across each node because it would be too many systems trying to hit my Orion API, so i just had a scheduled task on my server that took care of these kinds of things across all my templates as often as I needed, maybe hourly or daily. This model worked pretty well for me in an environment with 10k monitored servers and I would use similar SAM automations to do all kinds of things to my SAM templates that were inconvenient