|
Replies:
12
-
Pages:
1
-
Last Post:
Nov 30, 2009 8:10 AM
by: Jason Benway
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Script help. Adding computer name to output
Posted:
Nov 24, 2009 6:14 PM
|
|
|
I'm trying to read in a list of computers and output the mapped drives. I have it working, but the output doesn't like the computer name. Here's what I have.
gc c:\jb.txt |% {gwmi -computer $_ -query "Select * From Win32_LogicalDisk Where DriveType = 4" } | ft computer,DeviceID, ProviderName
|
|
|
Posts:
436
Registered:
12/15/08
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 24, 2009 8:26 PM
in response to: Jason Benway
|
|
|
Hi Jason, Can you provide us the first two lines of jb.txt?
/chris
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 12:53 AM
in response to: Jason Benway
|
 |
Answered |
|
|
Format-Table cannot access members of Get-Content however, you can get the machine name from the WMI output, replace 'computer' with 'SystemName':
gc c:\jb.txt | % {gwmi -computer $_ -query "Select * From Win32_LogicalDisk Where DriveType = 4" } | ft SystemName,DeviceID, ProviderName
Message was edited by: Shay Levy
|
Shay Levy [MVP]
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 7:47 AM
in response to: Shay Levy
|
|
|
awesome, thank you.
where do I findout what other fields/values I could grab with 'gwmi -computer $_ -query "Select * From Win32_LogicalDisk Where DriveType = 4" ' ?
When I manually run gwmi -query "select * from win32_logicaldisk where drivetype = 4" systemname is not in the output or is it format-table that gives me the additional fields/values?
thanks,jb
|
|
|
Posts:
436
Registered:
12/15/08
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 8:03 AM
in response to: Jason Benway
|
 |
Helpful |
|
|
Try these:
gwmi -query "select * from win32_logicaldisk where drivetype = 4" | get-member
gwmi -query "select * from win32_logicaldisk where drivetype = 4" | format-list *
-Chris
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 8:11 AM
in response to: seaJhawk
|
|
|
Thanks, I've updated the script so I can output it to a csv. now I have gc c:\jb.txt | % {gwmi -computer $_ -query "Select * From Win32_LogicalDisk Where DriveType = 4" } | Select-Object SystemName,DeviceID, ProviderName | Export-Csv c:\drivelist.csv -NoTypeInformation
But the strange thing is this only seems to work on my computer. I have three computer names in the jb.txt file (mycomputer,computer in a different domain, computer in same domain) I can ping all by hostname, I know I have permissions on the computer in the current domain.
the funny thing is I got get an error. I can run it manually from a PS commandline and it just returns to the prompt with no results and no errors.
Running gwmi -computer othercomputer -query "Select * From Win32_LogicalDisk Where DriveType = 4"
returns nothing and I know they have drives mapped
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 8:18 AM
in response to: Jason Benway
|
|
|
I figured out why I'm not getting data on the remote computers.
I'm looking for DriveType = 4 which is a list of their mapped drives.
The script doesn't seem to be pulling wmi information for the currently logged in user.
If I remove the where part of my select statment I get information about the c: drive of the other two computers. But I need information on the mapped drives of the logged in user.
Any way to get that?
thanks,jb
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 10:36 AM
in response to: Shay Levy
|
|
|
same results. nothing returned for a remote computer. Looks like I may have to try to do this via logon script :-(
|
|
|
Posts:
436
Registered:
12/15/08
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 1:49 PM
in response to: Jason Benway
|
|
|
Jason, Keep trying with the Win32_MappedLogicalDisk class. I've had success using it.
-Chris
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 25, 2009 2:47 PM
in response to: seaJhawk
|
|
|
are you saying you've successfully pulled mapped drives from remote computers with other user logged in?
|
|
|
Posts:
1,346
Registered:
1/31/08
|
|
|
Posts:
18
Registered:
7/21/09
|
|
|
|
Re: Script help. Adding computer name to output
Posted:
Nov 30, 2009 8:10 AM
in response to: Shay Levy
|
|
|
These are XP workstations so I changed the local policy to referenced in the link you posted to "administrators group" and rebooted the computer. but I'm still not getting the mapped drives. I'm even logged in as the same user has I'm running the PS from the other computer.
Thank you everyone for your help. I think I'm going to put my time into looking at a way to do this via logon script.
jb
|
|
|
|
Legend
|
|
MVP: 2501
+
pts
|
|
Guru: 2001
- 2500
pts
|
|
Expert: 751
- 2000
pts
|
|
Enthusiast: 31
- 750
pts
|
|
Novice: 0
- 30
pts
|
|
Moderators
|
|
Helpful answer
(5 pts)
|
|
Answered
(10 pts)
|
|