Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Log output of a function to file

$
0
0

Hey Guys,

I'm sure this question has been answered but I'm having a hard time finding the answer. My problem is that I can't figure out how to write the results of a function to a file. Sorry in advance if this is a newb question but I'm just learning Powershell. Here is the code:

function Log-Drives {$strComputer = "." 
$colItems = get-wmiobject -class "Win32_MappedLogicalDisk" -namespace "root\CIMV2" ` 
$env:COMPUTERNAME 

foreach ($objItem in $colItems) {  
      write-host "Caption: " $objItem.Caption 
      write-host "Compressed: " $objItem.Compressed 
      write-host "Device ID: " $objItem.DeviceID 
      write-host "File System: " $objItem.FileSystem 
      write-host "Free Space: " $objItem.FreeSpace 
      write-host "Maximum Component Length: " $objItem.MaximumComponentLength 
      write-host "Name: " $objItem.Name   
      write-host "Provider Name: " $objItem.ProviderName  
      write-host "Session ID: " $objItem.SessionID 
      write-host "Size: " $objItem.Size 
      write-host "Supports Disk Quotas: " $objItem.SupportsDiskQuotas 
      write-host "Supports File-Based Compression: " $objItem.SupportsFileBasedCompression 
      write-host "System Creation Class Name: " $objItem.SystemCreationClassName 
      write-host "System Name: " $objItem.SystemName 
      write-host "Volume Name: " $objItem.VolumeName 
      write-host "Volume Serial Number: " $objItem.VolumeSerialNumber 
      write-host 
	} 
} 

Thanks for the help guys


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>