Forum Discussion

Lucky1998's avatar
Lucky1998
Copper Contributor
Jul 17, 2020

Correct my powershell please. Set-MsolUserLicence

Hey Guys relatively new to Powershell but creating a termination script. all working well and good apart from this section to remove 365 licences.   This is what i want to be able to do but doesn't...
  • VasilMichev's avatar
    VasilMichev
    Jul 17, 2020

    Oh sorry, I thought it was the other way around, my bad. So basically, you need to get just the UPN value, not the object. Either use

     

    $upn.UserPrincipalName

     

    or set the value like this:

     

    $upn = Get-AdUser blabla | select -ExpandProperty UserPrincipalName

Resources