This is the error message I receive...
Error: SELECT clause: Semantic Error: 1st argument of function REPLACE_CHR must be a STRING
Invoke-Item : Cannot find path 'C:\chart_testpc.gif' because it does not exist.
At C:\chart-driveSpace.V2.ps1:44 char:12
+ Invoke-Item <<<< .\"chart_"$serverName".gif"
+ CategoryInfo : ObjectNotFound: (C:\chart_testpc.gif:String) [Invoke-Item], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.InvokeItemCommand
Here is the Powershell script I am using...
begin {
# function found on
sepeck's blog | Black Mountain
function Get-DriveSpace([string]$SystemName ) {
$driveinfo = get-wmiobject win32_logicaldisk -filter "drivetype=3 or drivetype=4" -computer $SystemName
$driveinfo | select deviceid, `
@{Name="FreeSpace";Expression={($_.freespace/1GB).tostring("0.00")}}, `
@{Name="DriveSize";Expression={($_.size/1GB).tostring("0.00")}}, `
@{Name="Percentfree";Expression={((($_.freespace/1GB)/($_.size/1GB))*100).tostring("0.00")}}
}
}
Process {
$logparser = "c:\Program Files\Log Parser 2.2\LogParser.exe"
$serverName = $_
if ($serverName -eq $Null) {
$serverName= $env:COMPUTERNAME
}
Get-DriveSpace $serverName | Export-Csv $env:temp"\temp.csv" -NoTypeInformation
& $logparser "select deviceid, TO_REAL (REPLACE_CHR (percentfree, ',', '.')) as purcentage into chart_$serverName.gif from $env:temp\temp.csv order by deviceID desc" "-o:chart" "-charttype:BarStacked" "-charttitle:Purcentage : FreeSpace by disk Server:$serverName" "-values:ON" "-categories:ON" "-maxCategoryLabels:100"
Invoke-Item .\"chart_"$serverName".gif"
}
Can anyone help?