![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| Guest | Call depth reached when calling function Please help...I am calling this function to try and output a perf counter value but I am getting call depth reached 101. I suspect I am recursing the fuction but not sure how else to output the value of the counter as the result of the function. Thanks in advance for any advise. Function PerfCounterValue() { #Connect to the local MSExchangeNMC Message Queued Outbound Performance Counter to read value $CounterDetail = "MSExchangeNMC","Message Queued Outbound","", $Computer $perf = New-Object System.Diagnostics.PerformanceCounter($CounterDetail) PerfCounterValue = $perf.RawValue #Check for errors in case counter could not be accessed ErrorCheck } $LastPerfCounterValue = PerfCounterValue If ($LastPerfCounterValue -eq $null) {Exit } |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Call depth reached when calling function Try changing this line PerfCounterValue = $perf.RawValue to $perf.RawValue Yours is currently similar to a VBScript style function, where you specify the return value in the name of the function. It works slightly differently in Powershell - you can just write the value you want returned on a line by its own, or you could also use a return statement return $perf.RawValue -- Jon "Victag" <miketaggart@xxxxxx> wrote in message news:5a3a79fa-2144-4712-950f-57ccc8ab20aa@xxxxxx Quote: > Please help...I am calling this function to try and output a perf > counter value but I am getting call depth reached 101. I suspect I am > recursing the fuction but not sure how else to output the value of the > counter as the result of the function. Thanks in advance for any > advise. > > Function PerfCounterValue() > { > #Connect to the local MSExchangeNMC Message Queued Outbound > Performance Counter to read value > $CounterDetail = "MSExchangeNMC","Message Queued Outbound","", > $Computer > $perf = New-Object > System.Diagnostics.PerformanceCounter($CounterDetail) > PerfCounterValue = $perf.RawValue > #Check for errors in case counter could not be accessed > ErrorCheck > } > > $LastPerfCounterValue = PerfCounterValue > If ($LastPerfCounterValue -eq $null) > {Exit > } |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Re: Calling excel function | VB Script | |||
| Re: Calling function from script | PowerShell | |||
| Call function with parameters that also call functions (.Net and P | PowerShell | |||
| Problems calling a function | PowerShell | |||
| calling imapi2 function put_MultisessionInterfaces return error | Vista General | |||