Home Forums SQL Server 2008 SQL Server 2008 Administration Powershell: "a positional parameter cannot be found that accepts argument 'system.object '" RE: Powershell: "a positional parameter cannot be found that accepts argument 'system.object '"

  • Here it is :

    param ( [string]$ComputerName = "." )

    Get-WmiObject -computername "$ComputerName" Win32_LogicalDisk -filter "DriveType=3" | foreach {

    add-member -in $_ -membertype noteproperty UsageDT $((Get-Date).ToString("yyyy-MM-dd"))

    add-member -in $_ -membertype noteproperty SizeGB $([math]::round(($_.Size/1GB),2))

    add-member -in $_ -membertype noteproperty FreeGB $([math]::round(($_.FreeSpace/1GB),2))

    add-member -in $_ -membertype noteproperty PercentFree $([math]::round((([float]$_.FreeSpace/[float]$_.Size) * 100),2)) -passThru } |

    Select UsageDT, SystemName, DeviceID, VolumeName, SizeGB, FreeGB, PercentFree

    This comes from this article :

    http://www.sqlservercentral.com/articles/powershell/65196/