ps/Modules/Alkami.PowerShell.Common/Public/Get-SetDifference.ps1

41 lines
490 B
PowerShell
Raw Normal View History

2023-05-30 22:51:22 -07:00
function Get-SetDifference {
<#
.SYNOPSIS
Returns List $a minus the entries of List $b
#>
[CmdletBinding()]
Param (
[Parameter(Mandatory=$true)]
[AllowNull()]
[object]$a,
[Parameter(Mandatory=$true)]
[AllowNull()]
[object]$b
)
if(!$a)
{
return $null
}
if(!$b)
{
return $a
}
$results = @();
$map = @{};
foreach($key in $b) {
$map.Add($key, '1')
}
foreach($key in $a) {
if(!($map.ContainsKey($key))) {
$results += $key
}
}
return $results
}