'Remove array from array in powershell

I have 2 arrays like this:

$array1 = @('Item10', 'Item20', 'Item30', 'Item40')

$array2 = @('Item1', 'Item3')

I would like to have my final array like this:

$arrayfinal = @('Item30', 'Item40')

meaning: find 'like' Item1 from array2 in array1, so remove it !

I tried: with the '-like' operator, the '-ne' operator, tried to add '*' and use the 'like' operator but could not find what I want.

Thanks for your help



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source