TryingI am trying to automate my O365 licensing and have had some sucesssuccess, but I am not sure how iI can accomplish the following...
I have users who iI do not wish to license and they all share the value "svc" in their DisplayName.
In trying to test how this would work i'mI'm dumping the values returned out to a CSVCSV file, but no matter what iI do iI cannot exclude users with those values in their names. I can do a "contains" and it finds just them...but when iI try a "notcontains" iI just get all of the users including those with SVC"svc" in their name.
Does anyone know how iHow can I exclude users that have svc"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
}
}