' Notes: ' - Fill in the connection information prior to running this script, or use ' supported command line options as desribed below. ' ' - Change value of strLogFile variable below to reflect log file where you ' desire debugging/troubleshooting information to be stored. ' ' Usage: ' CScript /Nologo "path_to_this_script" [named_options] ' ' Where [named_options] supported are: ' /host:yourHostname ' /port:yourHostPort ' /user:yourUsername ' /pass:yourPassword ' ' For example: ' CScript C:\RemoteDiskUsage.vbs /host:192.168.0.1 /user:bob /pass:p4$$w0rd Set objLicense = CreateObject("vralib.License") objLicense.AcceptEvaluationLicense ' Create an SSH2 connection object Set objConnection = CreateObject("vralib.Connection") '------------------------------------------------------ ' Set up logging to assist in debugging connection failures if any occur. ' Default log file path: strLogFile = "C:\Temp\vralib-du-debug-log.txt" ' Check to see if the log file exists on the local file system and delete it ' prior to connecting so that it only contains debug information for the most ' recent connection attempt. Set objLocalFSO = CreateObject("Scripting.FileSystemObject") If objLocalFSO.FileExists(strLogFile) Then objLocalFSO.DeleteFile(strLogFile) ' Set the log file path: objConnection.DebugLogFile = strLogFile ' Set the debug level to a value between 1(standard) and 9(packet level logging ' with auth-passwords masked) objConnection.DebugLevel = 5 '------------------------------------------------------ ' Set up default connection information objConnection.Hostname = "myhostname" objConnection.Port = 22 objConnection.Username = "myusername" objConnection.AuthenticationMethods = "password" objConnection.Password = "mypassword" ' Check for any non-default named command line arguments that may be present, ' e.g.: ' /host:192.168.0.131 /port 9922 /user:myusername /pass:mypasswd If WScript.Arguments.Named.Exists("host") Then objConnection.Hostname = _ WScript.Arguments.Named("host") If WScript.Arguments.Named.Exists("port") Then objConnection.Port = _ CInt(WScript.Arguments.Named("port")) If WScript.Arguments.Named.Exists("user") Then objConnection.Username = _ WScript.Arguments.Named("user") If WScript.Arguments.Named.Exists("pass") Then objConnection.Password = _ WScript.Arguments.Named("pass") ' Instruct VRALib's SSH component to accept server host keys automatically since ' we're in a script, and won't be able to do so manually. Normally, one would ' pre-populate the hostkey database with known host keys using the ' vralib.HostKeyDatabase object. objConnection.AutoAcceptHostkey = True ' Connect to the remote host objConnection.Connect ' Get a reference to a vralib FileSystemObject for the remote. Set objRemoteFSO = objConnection.FileSystemObject ' Enumerate drives, where possible -- Only VShell 3.8 and newer versions support ' drive enumeration via the "get-volume-information@vandyke.com" extension. vDriveTypes = Array("Unknown", "Removable", "Fixed", "Network", "CD", "RAMDisk") Set colDrives = objRemoteFSO.Drives For Each objDrive In colDrives If vDriveTypes(objDrive.DriveType) = "Fixed" Then WScript.Echo "Drive Path: " & objDrive.Path & vbcrlf WScript.Echo "File System: " & objDrive.FileSystem nTotalSize = Round(objDrive.TotalSize/1024^3,1) nFreeSpace = Round(objDrive.FreeSpace/1024^3,1) nPercentFree = FormatPercent(nFreeSpace/nTotalSize) WScript.Echo "Total size: " & nTotalSize & " GB" WScript.Echo "Free space: " & nFreeSpace & " GB" WScript.Echo "Percent free: " & nPercentFree & vbcrlf & String(60, "_") Else WScript.Echo _ "Skipping " & vDriveTypes(objDrive.DriveType) & " drive """ & _ objDrive.Path & """" & vbcrlf & String(60, "_") End If Next ' Disconnect from the SSH2 server objConnection.Disconnect