BRONZE PARTNER:
BRONZE PARTNER:
Industry News:

| |
| |
 |
 |
 |
 |
 |
| PowerShell Script To Get Network Drive Information From A List Of Machines |
 |
|
|
By: Don Hite
Posted On: 6/27/2007
This article was Previously posted on Don Hite's Blog
This PowerShell script will take the machine names from a text file called MachineList.Txt file and return the network drive letters and the full UNC path for them and write the results to an excel spreadsheet.
PS1 Script:
$Excel = New-Object -Com Excel.Application $Excel.Visible = $True $WorkBook = $Excel.WorkBooks.Add() $WorkSheet = $WorkBook.WorkSheets.Item(1) $WorkSheet.Cells.Item(1,1) = "Machine Name" $WorkSheet.Cells.Item(1,2) = "Drive" $WorkSheet.Cells.Item(1,3) = "Path" $CellRange = $WorkSheet.UsedRange $CellRange.Interior.ColorIndex = 19 $CellRange.Font.ColorIndex = 11 $intRow = 2 $colComputer = Cat C:\MachineList.txt ForEach ($strComputer in $colComputer) {$colComputer = Gwmi Win32_LogicalDisk -filter "DriveType = 4" -Comp $strComputer ForEach($objItem in $colcomputer){ $Worksheet.Cells.Item($intRow, 1) = $strComputer.ToUpper() $Worksheet.Cells.Item($intRow, 2) = $objItem.DeviceID $Worksheet.Cells.Item($intRow, 3) = $objItem.ProviderName
$intRow = $intRow + 1}} $Cellrange.Font.Bold = $True $Cellrange.EntireColumn.AutoFit() Clear
|
 |
 |
 |
|
|