Trying to automate my O365 licensing and have had some sucess but am not sure how i can accomplish the following...
I have users who i do not wish to license and they all share the value "svc" in their DisplayName.
In trying to test how this would work i'm dumping the values returned out to a CSV file but no matter what i do i cannot exclude users with those values in their names. I can do a "contains" and it finds just them...but when i try a "notcontains" i just get all of the users including those with SVC in their name.
Does anyone know how i can exclude users that have svc in their names? Here is my code....
$SyncUser = get-msoluser -all | Where-Object { $_.isLicensed -ne "TRUE" }
Foreach ($a in $SyncUser){
if ($a.DisplayName.NotContains("svc")) {
add-content -value ($a.Userprincipalname) -path $Logfile
}
}