Hi all – I'm trying to create a script that will give me the diskspace of multiple remote servers and display to screen (will build functionality to this later). At present I cna get the script to cycle through a text file and provide out but it's all data from the first server in the list, See code and output below.
$name = get-content "c:\scripts\servers.txt"
foreach ($SERVER in $name)
information for server1
Deviceid Size(GB) FreeSpace(GB) PercentFree
Can anyone point me in the right direction?
Try this function: Powershell script to get disk information including block size
So I can get the information I need using the below however I can't get the computer name between the data so I tell what relates to each server.
C:\Windows\system32> Get-WmiObject Win32_logicaldisk -ComputerName server1, server2, server3 `
DeviceID MediaType Size(GB) Free Space(GB) Free (%)
Answering from phone, otherwise I would give code. The advance toolmaking book from Mr. Jones has some great examples for what y are doing. My function find-smbshare on the powershell gallery may also help.
I think your 1st code is just missing the -computername param with get-ciminstance so it loops through each $server
You must be logged in to reply to this topic.