Skip to main content
added tag PS
Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61
added tag PS
Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61
Copy edited (e.g ref. <https://en.wiktionary.org/wiki/who%27s#Usage_notes>).
Source Link

Exclude users who'swhose names contain

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
    }
}

Exclude users who's names contain

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
}
}

Exclude users whose names contain

I am trying to automate my O365 licensing and have had some success, but I 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.

How can I 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
    }
}
edited
Link
Amal Hashim
  • 28.4k
  • 5
  • 32
  • 61
Loading
Tweeted twitter.com/#!/StackSharePoint/status/549125928472031232
Source Link
Jacob A
  • 701
  • 4
  • 18
  • 33
Loading