What is the format suppose to be for the strings which represent computer names and the partition?
The reason why I am asking is that my free space is always returning zero on the powershell session? This is not correct, because the real free space is 60 gigs.
This is the code used
$ConvertToGB = (1024 * 1024 * 1024)
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $ip -Filter $partition | Select-Object Size,FreeSpace
$ip + $partition + $description + ([math]::round(($disk.Size / $ConvertToGB),2)) + "GB" + "," + ([math]::round((($disk.FreeSpace / $ConvertToGB)),2)) + "GB"
Can someone please advise if the something is needed to be added to the strings for the computer name and partition name? Or perhaps special characters or extra commas or quotes etc???
I advice You do not write such a long code if you get any error ;^)
AS Noted above the DeviceId MUST include the :
DeviceId is the key property for the class. The correct usage is shown on the Path and __Relpath properties
Looking at you code you can make some improvements to take advantage of PowerShell's builtin features
$computername = $env:COMPUTERNAME
Get-WmiObject -Class Win32_LogicalDisk -ComputerName $computername |
Output an object rather than a string
You must be logged in to reply to this topic.