I have 2 Arrays
$Array1 = Get-Disabledusers SIDS
$Array2 = %Unnecessarytext(SIDS).VHDX
I need to compare Array1
and Array2
and output only the things in Array2
that contain Array1
.
Thing is, when I compare both objects, it returns not equal because they don't match exactly.
How do I get it to output the items in Array2 that contain the matching Disabled Users SIDS? Should I run a foreach loop and compare a part of the Array?
I found this: How to find if Powershell Array Contains Object of Another Array
However this doesn't help as it will return not equal.
Clarified Question:
There is a folder in which there are VHDXs. The VHDXs are named based on a user's SID. However, there is a bunch if unnecessary text before and after the SIDs.
In Array1, I run:
Get-ADUser -Filter {Enabled -eq $false} | FT SID
In order to retrieve a list of disabled users and filter out their SIDs.
In Array2, I list the names of the files in the VHDX folder which look like this: text SID text
. I want to compare both and return which files in the VHDX folders contain the SIDS of the disabled users.