I have two arrays one is having DLs current membership details $DL = @() and another one is having all Users Profile Data from Okta which i get it by API call $okta().
$DL = @()
$okta = @()
$Okta | ForEach { if (($.Manager -eq “XYZ”) -and ($DL.PrimarySMTP -notcontains $.email) )
{$NewMember += @($_)}
}
I get don’t get new member details in $NewMember but i get details who are already in the DL. can anyone help me with this
Thank you
Few missing pieces.
The $DL variable yo provided is empty. Hence property ‘PrimarySMTP’ cannot be used. Variable $okta is also empty.
I believe DL variable will have list of mail IDs. But difficult to guess. Pleas share the values(sample) if possible.
You can assume something like this
$DL = @()
$DL = Get-DistributionGroupMember “some-DL” -ResultSize unlimited
$okta = @() # let’s assume it has User data which we got it from Okta API using invoke-restmethod commandlets
It has user profile like first name last name and email id etc
basically i am querying this metadata for new hire joining to some manager’s team and same time I am validating that if user is already in the DL
unfortunately I am not getting new user who is in the $okta but not in the DL
Hope this is clear
HI rpsingh
while querying $_.Manager -eq “XYZ” can you validate the value XYZ seems problem with there, as you used the equal operator(-eq) it needs to be the exact match or else you can try with -like operator,unless all other values present correctly.
I suggest you to use an editor (VSCode or PowerShell ISE), save this code as script and put a break point on if condition and debug. THis will give you the reason for unexpected behavior. You can share the results here.