I am running below powershell script to get the disk space information from list of servers but i have been getting below error while running this script,
I am quite new to powershell and did some research and could find the solution.
Error
An Empty pipe element is not allowed.
At line:6 char:81
+ @{Label = 'Free Space (%) ; Expression = {"{0:P0}" -f }} | <<<<
+CategoryInfo : ParserError: <:> [], ParentContainsErrorrecordsException
+ FullyQualifiedErrorId : EmptyPipeElement
$DiskReport |
Select-Object @{Label = "Server Name";Expression = {$_.SystemName}},
@{Label = "Drive Letter";Expression = {$_.DeviceID}},
@{Label = "Total Capacity (GB)";Expression = {"{0:N1}" -f( $_.Size
/ 1gb)}},
@{Label = "Free Space (GB)";Expression = {"{0:N1}" -f(
$_.Freespace / 1gb ) }},
@{Label = 'Free Space (%)'; Expression = {"{0:P0}" -f
($_.freespace/$_.size)}} |
Export-Csv -path "c:\data\server\ServerStorageReport\DiskReport\DiskReport_$logDate.csv" -NoTypeInformation