I have this powershell code which goes through a list of servernames in a text file and outputs the corresponding values as here.CODE:$Results = Foreach ($Server in (get-content "C:\serverlist\Server.txt")) {Get-WmiObject Win32_LogicalDisk | Select DeviceID,VolumeName,Drive,DriveType,Size,FreeSpace | Format-Table }$Results | Out-File "C:\serverlist\ServerDetails.txt"The current code is printing only the output on the server where I am runnig this code.So if there 6 servers it is printing the same output 6 times.How can I also add the corresponding servername as one more additional column in the output?And also I do not want to repeat the column names as in the attached output.My result should look like this as below:So there should not be an extra line as in the attached file after the column headings.Also for each server the column names are repeating here as in the output attached.It should not happen.Everything should be in tab delimited format as I will be importing this into a SQL table.ServerName DeviceID VolumeName Drive DriveType Size FreeSpace ABCD A: ABCD C: 3 96528756736 41185206272 ABCD D: ABCD E: Data 3 64421359616 30061256704 ABCD F: Logs 3 32209104896 615387136 EDGF A: EDGH C: 3 96528756736 41185206272 EFGH D: EFGH E: Data 3 64421359616 30061256704 EFGH F: Logs 3 32209104896 615387136 Attached is the current output.Thanks
↧