The members of ControlUp discuss the possibility of using a Scoutbees Shell Execution scout to check the availability of a network share. Some members recommend using a PowerShell script for this purpose, while others suggest doing a TCP port 445 test. After some troubleshooting, one member shares their successful method of using a PowerShell script with the Share permissions set to "everyone."
Read the entire ‘Troubleshooting Network Share Availability with ControlUp Scouts’ thread below:
Good day
With scoutbees
Is there a way to see if a network share is available ?
AFAIK not out of the box, but you can maybe use a Script (Test-Path $netsworkshare) with an Shell Execution scout!?
Ok awesome
The shell will then be PowerShell
And the argument with then be the path to the script ?
To be honest I never used a Shell Exec scout because I had no use case. Until today 😄
Will try in Lab later and let you know…
I assume you will have to write the script which will check the network share which have to be available on the custom hive running the script.
I like power shell so that I can do
Just need some advise to run the script
You could do a tcp port 445 test. It at least tells you if a fileserver has SMB open. But to test it fully, the shell execution test is the way to go
i did it via a PS script action
@member
Must the script be on the device somewhere ?
And if so do just add this to the shell field ?
powershell.exe -ExecutionPolicy Bypass -File "C:\path\to\your\script.ps1"
@member do you mind sharing what and how you did it ?
Currently in the lab… Seems the script is working though:
“`$share = "\mze-filer-01.lab.brainc1on.de\config"
$checkShare = Test-Path -Path $share
If ($checkShare) {
#Write-Host "Its alive!"
exit 0
} else {
#Write-Host "Its dead!"
exit 666
}“`
I am just fiddling with the exit codes 🙂
Thank you thank you
i put a test file in the share and I have PS look for it
So my script from posted above works in scoutbees with the following config which is quite the same as Brian have.
Just wanted to finish it 😄
looks like mine isn’t working
File: powershell.exe
Arguments: -file c:\tech\scripts\find_files.ps1
Date: Thu, 12 Sep 2024 12:09:11
Exit Code: 0
STDERR Length: 0 b
STDOUT Body:
False
you all are awesome
again i love this community
looking more closely at mine. It reports success even if the output is false.
Not sure How i would make scoutbees interpret the results better
Here is a failure:
“`File: powershell.exe
Arguments: -file c:\tech\scripts\find_files.ps1
Date: Thu, 12 Sep 2024 11:09:12
Exit Code: 0
STDERR Length: 0 b
STDOUT Body:
False“`
Here is a success:
“`File: powershell.exe
Arguments: -file c:\tech\scripts\find_files.ps1
Date: Thu, 12 Sep 2024 12:09:21
Exit Code: 0
STDERR Length: 0 b
STDOUT Body:
True“`
Mine is working quite fine.
If I check it against a non existing share I get the return code 666 I put in my script and scoutbees shows a failure:
@member if your script is just that one line "Test-path…" then you will always get 0 as ExitCode which scoutbess interprets as "successful".
You need to work with exit codes (like I do in my script).
The "Test-Path" just returns a $false if the path you’re checking is not existing but the result of the script is ErroCode 0 anyways…
i get no output using yours.
Woks for me
One is successful then turn off the share on the server and it worked with the fail
i’m getting an access denied. Did you have to grant any ntfs or SMB permissions to the share folder?
STDERR Length: Test-Path : Access is denied At C:\tech\scripts\1find_files.ps1:2 char:15 + $checkShare = Test-Path -Path $share + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (\SERVER) [Test-Path], UnauthorizedAccessExcepti on + FullyQualifiedErrorId : ItemExistsUnauthorizedAccessError,Microsoft.PowerShell.Commands.TestPathCommand b
Gave the service account that is singed in on the scoutbees config access to the share and it worked
local system?
It’s the local admin yes
didn’t seem to help
Server team is offline its almost 8 pm here asked for a screenshot on the permissions will share one I get it
If you just want to check the availability of the share you don’t need NTFS (Security) permissions…
Make sure you set the Share permissions (if allowed by company policy) to everyone, then it should work.
If you want to check for an existing file you need (obviously) NTFS read permissions…
yup, i have share set to everyone full control
Continue reading and comment on the thread ‘Troubleshooting Network Share Availability with ControlUp Scouts’. Not a member? Join Here!
Categories: All Archives, ControlUp Scoutbees, ControlUp Scripts & Triggers