Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
PowerShell Script To Get Network Drive Information From A List Of Machines


Bookmark and Share

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


  myITforum.com ©2010 | Legal | Privacy