Monitor network drive access with SCOM and PowerShell

Continuing our monitoring with SCOM and PowerShell scripts series, this time I’ll share a script I wrote to monitor network drive access.
Network drives are not discovered by SCOM and thus are not monitored, and network drives access can be a key element in some of todays applications so monitoring them becomes critical.

Using the following PowerShell script you can enforce the SCOM agent located locally on the machine to try and access the network drive.

Be aware that SCOM uses its own user rights to access the path. That means that if the SCOM Default Action Account has no rights to the drive – it won’t be able to monitor it. More over, if you have a network drive that must be accessed by a specific user and you wish to run the script with that user’s permission – it won’t work. I’m working on a solution to this problem and will post it as soon as I come up with it.

Having said that, lets review the script

# NAME: Test.Network.Drive.Status.Ps1

# Arguments passed to Script:
# $DriveLetter = Mapped drive letter
# CREATED : 19/10/2015
# CREATED BY : Yury Kissin, XperInt
# Contact :


$ErrorActionPreference = "stop"
$Message = $null

$PropertyBagAPI = New-Object -ComObject "MOM.ScriptAPI"
$PropertyBag = $PropertyBagAPI.CreatePropertyBag()

$PropertyBagAPI.LogScriptEvent("Test.Network.Drive.Status.Ps1",9999,0,"Begin executing monitoring script")

$Path2Check = $Arguments # + "\Test.Network.Drive.Status.txt"

if(!(Test-Path $Path2Check)){
$Message = "Cannot access drive letter $Arguments"



If you follow this blog you will see a familiar pattern here 🙂

The PowerShell script receives the network drive letter as a parameter. For example “T:” (without the quotes””)

If you look at line 22, you’ll see that the script basically checks access to the path it self (T:, in our example). You can create a file on that drive and simulate access to it by deleting the “#” that follows.

And that’s about it, everything else is pretty straight forward.

As always, feel free to comment and asks questions in the comments section.



What do you think about this post?