none
Assigning Msol Licenses as Job RRS feed

  • Question

  • Hey guys,

    I'm in the process of completely automating our hybrid environment's onboarding and offboarding process.

    I'm almost there but I've run into a small snag and that's assigning a license as a job, if that's even currently the best approach.

    We have a parser that creates a remote mailbox, then runs set-aduser to fill in the street/phone/etc of that person. The last step is assigning a license. Now one method I could do is do the aforementioned stuff and then start a really long sleep while the system DirSyncs and the user has a chance to appear in Office 365, but I was curious if a job would be a better approach?

    For example:

    $creds = Import-CliXml c:\auto\auto.xml
    
    Connect-MsolService -credential $creds
    $assign = {
    Start-Sleep 60
    Set-MsolUser -UserPrincipalName gpig@ver.com -UsageLocation "US"
    Start-Sleep 3
    Set-MsolUserLicense -UserPrincipalName gpig@ver.com -AddLicenses "ver:DESKLESSPACK"
    
    }
    
    Start-Job -ScriptBlock $assign
    
    

    When I check the guinnea pig account, it's unlicensed still.

    Is this a badway to do it? :( 

    Tuesday, September 11, 2018 12:19 AM

Answers

  • You have to connect in the job.  A job is a separate PS process and must be treated as if you just started PS.


    \_(ツ)_/

    • Marked as answer by ChrisVERit Tuesday, September 11, 2018 12:39 AM
    Tuesday, September 11, 2018 12:27 AM

All replies

  • You have to connect in the job.  A job is a separate PS process and must be treated as if you just started PS.


    \_(ツ)_/

    • Marked as answer by ChrisVERit Tuesday, September 11, 2018 12:39 AM
    Tuesday, September 11, 2018 12:27 AM
  • Of course it would be something dumb and overlooked like that

    Tuesday, September 11, 2018 12:39 AM