Array ForEach Type Conversion with Custom Object

Okay, I’m having a little trouble with some type conversion where I am not sure what function I need to have defined for the code to work right.

I am utilizing ConvertFrom-Json to load the object from a file. The line that I’m having trouble with is the $obj.JobList.ForEach([BackupJob]) line. I get an error that "Cannot find an overload for “Add” and the argument count “1”. I know I need to overload a function somewhere, but I’m not sure what.

I know I can get it to work by using a traditional foreach loop, but I’m wondering if there is an easy way to make it work with this line (mostly because I’m interested in how the mechanics behind the array.ForEach is working)

Below is a shortened version of my class definitions. A previous post of mine had a more full version if you want to see that.

class Backup
{
    [BackupJob[]]$Joblist

    Backup([PSCustomObject]$obj) {
        $this.Joblist = $obj.JobList.ForEach([BackupJob])
    }

}

class BackupJob
{
    [string]$MountPoint

    BackupJob([PSCustomObject]$obj) {
        $this.MountPoint = $obj.MountPoint
    }
}

Foreach on an object will be used like below.

$Obj.Foreach({$_})
# contents inside {} will be same as how we use it in Foreach-Object