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,38 @@
# Retrieve licences for a list of users and export them to a CSV file.
#
# Where is the list of user UPN's?
$userListPath = 'C:\Temp\UserList.txt'
# Import AzureAD module and connect
Import-Module AzureAD
Connect-AzureAD
# Get all available licence details
$allSkus = Get-AzureADSubscribedSku
# Import list of users from file
$users = Get-Content -Path $userListPath | Sort-Object
# Get Licences for user and find out what they are from the list
$allUserLicences = @()
foreach ($user in $users) {
$assignedLicences = @()
try {
$userDetails = Get-AzureADUser -ObjectId $user -ErrorAction Stop
foreach ($license in $userDetails.AssignedLicenses.SkuID) {
$assignedLicences += ($allSkus | Where-Object { $_.SkuID -eq $license }).SkuPartNumber
}
}
catch {
$assignedLicences = 'User not found.'
}
$userLicences = [PSCustomObject]@{
'UserName' = $user
'AssignedLicences' = (($assignedLicences | Sort-Object) -join ';')
}
$allUserLicences += $userLicences
}
# Export list to CSV file
$allUserLicences | Export-Csv -Path 'C:\Temp\UserLicences.csv' -NoTypeInformation