Unpublish item using Powershell

I have been working with a PowerShell script to publish things, and it has worked perfectly.

I am now trying to extend it to be able to unpublish items as well, but have not found the right command or the right set of parameters.

The error that I get is:

Cannot find an overload for "Publish" and the argument count: "5".

My code is:

$publishIntructionData = New-Object Tridion.ContentManager.CoreService.Client.PublishInstructionData
$publishIntructionData.RenderInstruction = New-Object Tridion.ContentManager.CoreService.Client.RenderInstructionData 
if ($jobPublishAction -eq "unpublish")
{
    $publishIntructionData = New-Object Tridion.ContentManager.CoreService.Client.UnPublishInstructionData
}
$publishIntructionData.ResolveInstruction = New-Object Tridion.ContentManager.CoreService.Client.ResolveInstructionData 
$publishIntructionData.ResolveInstruction.IncludeChildPublications = $allPublications
if ($jobPublushAction -eq "publish")
{
    $publishIntructionData.ResolveInstruction.IncludeWorkflow = $true
}
if ($jobPublishAction -eq "unpublish")
{
    # $publishIntructionData.ResolveInstruction.ResolvePurpose = New-Object Tridion.ContentManager.Publishing.ResolvePurpose.UnPublish
    # Unpublish = 1
    $publishIntructionData.ResolveInstruction.Purpose = 1
}

if ($scheduled -eq $true) {
    $publishIntructionData.StartAt = $scheduledDateTime
}

$result = $client.Publish($Id, $publishIntructionData, $publicationTarget, $priority, $readOptions)