I have written a simple SetDifference function, by using the Compare-Object function:
Function SetDifference {
param(
[Parameter(Mandatory=$true)]$ReferenceObject,
[Parameter(Mandatory=$true)]$DifferenceObject
)
Compare-Object $ReferenceObject $DifferenceObject |
Where-Object { $_.SideIndicator -eq '<=' } |
ForEach-Object { $_.InputObject }
}
I've noticed that ANY alias can be used without PowerShell complaining:
Set-Alias '\' 'SetDifference'
Set-Alias '.' 'SetDifference'
Set-Alias '+' 'SetDifference'
Shouldn't there be restrictions on what the alias name can be - to stop you from using symbols that are already part of PowerShell syntax?