Pull list of workstation mapped drives into K1000 inventory
Someone must have accomplished this by now. I don't seem to be able to figure it out, so I thought I would ask. I have a script which runs and puts a text file on the root of C: drive which contains the listing of the mapped drives for each pc. I would like to pull the contents of that text file into a custom inventory field in KACE. Any ideas on how to do so?
1 Comment
[ + ] Show comment
Answers (4)
Answer Summary:
Please log in to answer
Posted by:
jknox
10 years ago
Posted by:
dugullett
11 years ago
Enter this in your custom field.
ShellCommandTextReturn (cmd.exe /c type C:\Path\to\file\file.txt)
Comments:
-
Thanks that did the trick :) - KHaught 11 years ago
Posted by:
brighstarcuit
11 years ago
would love to creat the same report
Comments:
-
See this. This will get it setup. The report you should be able to get through the GUI. Since the software ID will be unique to your Kbox.
http://www.itninja.com/blog/view/inventorying-reporting-on-user-profile-specific-other-non-inventoried-data - dugullett 11 years ago -
Wow - Incredible wealth of Information in this post - Thank you very much, Dugullett. - KHaught 11 years ago
Posted by:
KHaught
10 years ago
PowerOverwhelming - here is the script I run to pull mapped drives. it works on Win 7 and XP both. We place all of our custom inventory field text files in a folder on C: called KBOX. You can modify this as needed as to where you want the file to go. This script is a conglomeration of info found here and on Google. I didn't write the whole thing, I just made it work for our situation. This script pulls all drive information, not just mapped drives. it pulls your local hard drives and any CD/DVD drives you may have installed also, and the locally logged on user at the time the script was run.
***********************************************************************************************************************************
Dim objFSO, newfolder
Dim strComputer, objWMIService
Dim fso, fsHandle, objShell,LogFileName, colItems, objItem
set objFSO=CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists("c:\KBOX") Then
newfolder = objFSO.CreateFolder ("c:\KBOX")
End If
Set objShell = CreateObject("Wscript.Shell")
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
If objFSO.FileExists("c:\KBOX\MappedDrives.txt") Then
fso.DeleteFile "c:\KBOX\MappedDrives.txt", True
End If
LogFileName= "C:\KBOX\MappedDrives.txt"
set fsHandle = fso.OpenTextFile (LogFileName,8,True)
sUser = ConsoleUser(".") ' use "." for local computer
Function ConsoleUser(sHost)
' Returns name of user logged on to console
' If no users are logged on, returns ""
Dim oWMI, colProc, oProcess, sUser, sDomain
Set oWmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(debug)}!\\" _
& sHost & "\root\cimv2")
Set colProc = oWmi.ExecQuery("Select Name from Win32_Process" _
& " Where Name='explorer.exe' and SessionID=0")
ConsoleUser = ""
For Each oProcess In colProc
lRet = oProcess.GetOwner(sUser, sDomain)
If lRet = 0 Then
ConsoleUser = sUser
End If
Next
End Function
fsHandle.Writeline Now & " - " _
& "Logged in user: " & suser _
fsHandle.Writeline "------------------------------------------------------"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 3")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & "Local Hard Drive"
Next
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 5")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & "CD/DVD Drive"
Next
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 4")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & objDrive.ProviderName _
Next
fsHandle.Writeblanklines 1
fsHandle.close
set objShell = Nothing
set fso = Nothing
***********************************************************************************************************************************
Dim objFSO, newfolder
Dim strComputer, objWMIService
Dim fso, fsHandle, objShell,LogFileName, colItems, objItem
set objFSO=CreateObject("Scripting.FileSystemObject")
If Not objFSO.FolderExists("c:\KBOX") Then
newfolder = objFSO.CreateFolder ("c:\KBOX")
End If
Set objShell = CreateObject("Wscript.Shell")
Set fso = Wscript.CreateObject("Scripting.FilesystemObject")
If objFSO.FileExists("c:\KBOX\MappedDrives.txt") Then
fso.DeleteFile "c:\KBOX\MappedDrives.txt", True
End If
LogFileName= "C:\KBOX\MappedDrives.txt"
set fsHandle = fso.OpenTextFile (LogFileName,8,True)
sUser = ConsoleUser(".") ' use "." for local computer
Function ConsoleUser(sHost)
' Returns name of user logged on to console
' If no users are logged on, returns ""
Dim oWMI, colProc, oProcess, sUser, sDomain
Set oWmi = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate,(debug)}!\\" _
& sHost & "\root\cimv2")
Set colProc = oWmi.ExecQuery("Select Name from Win32_Process" _
& " Where Name='explorer.exe' and SessionID=0")
ConsoleUser = ""
For Each oProcess In colProc
lRet = oProcess.GetOwner(sUser, sDomain)
If lRet = 0 Then
ConsoleUser = sUser
End If
Next
End Function
fsHandle.Writeline Now & " - " _
& "Logged in user: " & suser _
fsHandle.Writeline "------------------------------------------------------"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 3")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & "Local Hard Drive"
Next
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 5")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & "CD/DVD Drive"
Next
Set colDrives = objWMIService.ExecQuery _
("Select * From Win32_LogicalDisk Where DriveType = 4")
For Each objDrive in colDrives
fsHandle.Writeline objDrive.Name & " " & objDrive.ProviderName _
Next
fsHandle.Writeblanklines 1
fsHandle.close
set objShell = Nothing
set fso = Nothing
Thanks - anonymous_104535 10 years ago