I want to create a custom object with some properties, and some scripts that use those properties. I can figure out how to access the properties from within the script. Function that creates the object. Once property is “Count”. I have a ScriptMethod called “Step” that I would like to refer to the “Count” property defined.
Inside your script block, use the $this automatic variable instead of $_. I assume you meant that to be a += operator, not = (or Step would always assign the same value to X, over and over.)
Richard’s got a point, though, you’re kind of reinventing the wheel here. PowerShell has the Write-Progress cmdlet, and if that doesn’t meet your needs, you can also easily access the System.Windows.Forms.ProgressBar class, which has similar functionality to what you’ve shown so far (X = Value, Increment / Count = Step, Step() = PerformStep() , etc)
I am playing with the progress bar to see what I can do. I have looked at the System.Windows.Forms.ProgressBar also, and it doesn’t really have what I want either.