I am running a VBS HD Script from HostMonitor. If needed, I can post the code I am using. When I run this test against a Windows 7 station, it responds back with the primary Drive Letter, Percentage Free, and (GB Free). For example, C:42%(98.5).
When I run this test on a Windows 10 station, I get "Server not found or responding: Error #70 Permission denied."
I am using the Connection Manager, and I only have one domain account listed that has full Administrative privileges. HostMonitor is installed on a Windows 2008 R2 server, the workstations above are both on the same Domain.
I have verified that WMI is configured on both stations, along with Remote Registry. I can ping both stations by name and IP address. I can browse to each station thru Windows Explorer by name or IP, using the same Domain credentials.
Every Windows 10 station I run this test on replies with the same error. I have even tried putting the FQDN into the test with no change in result.
Any assistance would be much appreciated.
Code: Select all
cmd /c cscript /B /E:VBScript &Script% %Params%
Option Explicit
DIM sCompStatus, sType, sResult, sSyntaxDesc
DIM iThreshold
' *** Default Values & constants
iThreshold =.2
const statusAlive ="scriptRes:Host is alive:"
const statusDead ="scriptRes:No answer:"
const statusUnknown ="scriptRes:Unknown:"
const statusUnknownHost ="scriptRes:Unknown host:"
const statusOk ="scriptRes:Ok:"
const statusBad ="scriptRes:Bad:"
const statusBadContents ="scriptRes:Bad contents:"
const ShowSyntax ="/?"
' *** Parse the command-line arguments, check syntax, & perform necessary type conversions.
Select Case WScript.Arguments.Count
Case 0 ' *** No command line arguments
sCompStatus =ParseArg(".",0)
Case 1 ' *** Argument1 =computer name
sCompStatus =ParseArg(Wscript.Arguments(0),0)
Case 2 ' *** Argument2 =Critical threshold
sCompStatus =ParseArg(Wscript.Arguments(0),0)
iThreshold =ParseArg(Wscript.Arguments(1),1)
Case Else ' *** Maximum is 2 command line parameters - Show syntax
sCompStatus =ParseArg(ShowSyntax,99)
End Select
' *** If parsed arguments are 'bad' pass the results to StdOut
If InStr(sCompStatus,"scriptRes:") Then
WScript.StdOut.Write sCompStatus
ElseIf InStr(iThreshold,"scriptRes:") Then
WScript.StdOut.Write iThreshold
Else
' *** Otherwise call HDFreeTest Function & pass results to StdOut
WScript.StdOut.Write HDFreeTest(sCompStatus, iThreshold)
End if
' ===========End Script===========
'
' --------Functions & Subs--------
Function ParseArg(Arg, ArgNum)
' *** Purpose: Parse command-line arguments & display Syntax rules if necessary
DIM sReply, sSyntaxDesc
const Syntax ="Syntax: CSCRIPT HDFree.VBS {computer_name} {threshold}"
sSyntaxDesc = vbCrLf & "Where: {computer_name} =" & _
"name of a WMI enabled computer (local or remote)" & vbCrLf & _
vbTab & "{threshold} =minimum freespace" & vbCrLf & _
vbTab & vbTab & "An integer value is interpreted as physical size (in GB)" & vbCrLF & _
vbTab & vbTab & "A decimal value or an integer followed by '%%'" & vbCrLF & _
vbTab & vbTab & " is interpreted as a percentage" & vbCrLF & _
vbTab & vbTab & "Defaults: Computer: " & Chr(34) &"." & Chr(34) & _
" (local computer)" & vbCrLF & _
vbTab & vbTab & vbTab & " Threshold: 20%" & vbCrLF & _
"Inspired by Glynn Seymours adaptation of Rob van der Woude's freespace.vbs" & vbCrLf & _
vbTab & "http://www.robvanderwoude.com"
If InStr(Arg, "?") Then ArgNum =99
Select Case ArgNum
Case 0 ' *** sComputer Argument
ParseArg =CStr(Arg)
Case 1 ' *** iThreshold Argument
On Error Resume Next
If IsNumeric(Arg) Then
ParseArg =CSng(Arg)
Elseif InStrRev(Arg,"%")<>0 Then ParseArg =CSng(Trim(Left(Arg,InStrRev(Arg,"%")-1))/100)
Else
ParseArg =statusUnknown & "Syntax: Argument conversion error: " & Arg
On Error Goto 0
Exit Function
End If
If ParseArg <.01 or ParseArg >99 Then _
ParseArg=statusUnknown & "Threshold value out of bounds: " & Arg
On Error Goto 0
Case Else ' *** Display script syntax
ParseArg =statusUnknown & Syntax ' & sSyntaxDesc
' *** -------------------Remove this--^ if you wish to include Syntax Description
End Select
End Function
' --------------------------------
Function HDFreeTest(ArgComp, ArgThold)
' *** Purpose: Query Windows servers (WMI) for available Hard Disk free space
DIM sStatus, sReply
DIM iFree
DIM oWMIService, oItem, aItems
const GB=1073741824
On Error Resume Next
Set oWMIService =Getobject("winmgmts://" & ArgComp & "/root/cimv2")
If Err.Number Then
HDFreeTest =statusUnknownHost & "Server not found or not responding: Error # " & _
CStr(Err.Number) & " " & Err.Description
Exit Function
End If
Set aItems =oWMIService.ExecQuery("Select * from Win32_LogicalDisk where DriveType =3",,48)
If Err.Number Then
HDFreeTest =statusUnknown & "Error # " & CStr(Err.Number) & " " & Err.Description
Exit Function
End If
On Error GoTo 0
sStatus=statusOK
For Each oItem in aItems
If sReply<>"" Then sReply =sReply & ", "
'Calculate volume's percentage free space
iFree =Int(.5+(100 * oItem.FreeSpace / oItem.Size))
' *** If ANY volume falls below the critical threshold, set the AHM status to BAD
' *** then append this volumes free space and free space percentage to the return message
If iThreshold <1 Then
If iFree<iThreshold*100 Then sStatus =statusBad
sReply =sReply & oItem.Name & iFree & "%" & "(" & Round(oItem.FreeSpace / GB,2) & ")"
Else
If Round(oItem.Freespace / GB,2)<iThreshold Then sStatus ="statusBad"
sReply =sReply & oItem.Name & Round(oItem.FreeSpace / GB,2) & "(" &iFree & "%" & ")"
End If
Next
If sReply =Empty Then
HDFreeTest =statusUnknown & "Local Hard Disk(s) not found"
Else
HDFREETest =sStatus & sReply
End If
End Function