Added Files

This commit is contained in:
DistractADD
2021-07-06 13:16:46 +10:00
parent f2475a3bdd
commit cfddd4fad2
393 changed files with 65842 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
# Bulk add additional licences to a list of users where they already have a licence assigned.
#
# Only works where the user already has a licence assigned as assigning a licence to an unlicenced user is a different process.
#
# Where is the list of user UPN's?
$userListPath = 'C:\Temp\UserList.txt'
# What licences are we adding?
# List of available SKUs can be obtained with (Get-MsolAccountSku).AccountSkuId
$licencesToAdd = @('','')
# Import MSOnline module and connect
Import-Module MSOnline
Connect-MsolService
# Import list of users from file
$users = Get-Content -Path $userListPath | Sort-Object
# Add the new licence
foreach ($user in $users) {
$userDetails = Get-MSOLUser -UserPrincipalName $user
foreach ($licenceToAdd in $licencesToAdd) {
if ($userDetails.IsLicensed -eq $true) {
if (!(($userDetails.licenses).AccountSkuId -match $licenceToAdd)) {
Write-Output -InputObject ('Adding Licence ' + $licenceToAdd + ' to ' + $user + '.')
Set-MSOLUserLicense -UserPrincipalName $user AddLicenses $licenceToAdd
}
else {
Write-Output -InputObject ('User ' + $user + ' already has ' + $licenceToAdd + ' licence assigned.')
}
}
else {
Write-Output -InputObject ('User ' + $user + ' has no existing licence assigned.')
}
}
}