I have a custom C# PowerShell Cmdlet that I have written that outputs an object.
[Cmdlet(VerbsCommon.Get, "CustomObj")]
public class CustomObjGet : Cmdlet
{
protected override void ProcessRecord()
{
var instance = CustomObj.Get();
WriteObject(instance);
}
}
Usage:
$output = Get-CustomObj
The object returned has a method:
public class CustomObj
{
public string Name { get; set; }
public static CustomObj Get()
{
var instance = new CustomObj() { Name = "Testing" };
return instance;
}
public void RestartServices ()
{
// Want to WriteProgress here...
}
}
Usage:
$output.RestartServices()
As it stands now, that method doesn't have access to the Cmdlet WriteProgress function like you would in the ProcessRecord() method of the Cmdlet itself.
I'd like to do a PowerShell WriteProgress from within that method. Any ideas on how I can do that?