Assign licenses by OU


i'm working on changing our o365 licenses 8000+ users.  need assign student licenses accounts in 'student' ou.  need assign employee licenses users in other ous.  there way it?  how?

get-msoluser not output ou in it's out. 

i can filter users have old student license change license users without license?  likewise, can filter users have old employee license users without license?

currently have these scripts starting point:

get-msoluser -enabledfilter enabledonly -maxresults 2000 -unlicensedusersonly | fl

get-msoluser -all  | fl | {$_.licenses -contains 'standardwoffpack_student'}

get-msoluser -all  | fl | {$_.licenses -contains 'standardwoffpack_faculty'}

thanks help.

$users = get-aduser -filter * -searchbase ou=students,....

foreach($user in $users){

if(!((get-msoluser -userprincipalname $user.userprincipalname).licenses | ? {$_.accountskuid -eq 'standardwoffpack_student'})) {

set-msoluserlicense -userprincipalname $user.userprincipalname -addlicenses standardwoffpack_student -licenseoptions $options}

}

dan



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Indexing Server

Schannel Issue

oclist /xml or /?