I'm a super-noob when it comes to powershell. I've been able to extract the WMIobject win32_LogicalDisk info except for the ADComputer identity info. See my code and columns needed to populate. I keep getting a blank under user. Any thoughts?
$exportPath = "\\Server01\users\ohyeah\Downloads\testfolder"
$computers = Get-Content "\\Server01\users\ohyeah\Downloads\testfolder\computers.txt"
$driveinfo = Get-WMIobject win32_LogicalDisk -ComputerName $computers -filter "DriveType=3" | Select-Object SystemName, DeviceID, VolumeName,
@{Name="Size_GB"; Expression={"{0:N1}" -f($_.size/1gb)}},
@{Name="FreeSpace_GB"; Expression={"{0:N1}" -f($_.freespace/1gb)}},
@{Name="%_FreeSpace_GB"; Expression={"{0:N2}%" -f(($_.freespace/$_.size)*100)}},
@{Name="User"; Expression={$(Get-ADComputer -identity $_ -Properties Description | ft -a Description)}},
@{Name="Date"; Expression={$(Get-Date -format 'g')}}
$driveinfo | Out-GridView
$driveinfo | Format-Table -AutoSize
$driveinfo | Export-Csv "$exportPath\test.csv" -NoTypeInformation -NoClobber -Append
SystemName DeviceID VolumeName Size_GB FreeSpace_GB %_FreeSpace_GB User Date
User
calculated property? does theexpression
part of that line run correctly when you run it alone in your loop? – Lee_DaileyGet-WMIObject
sends on an object that contains the property PSComputer if I remember right. Try-identity $_.PSComputer
and see if that helps. – TheMadTechnician