add: 1.1.1 test as automated and organized csv.

This commit is contained in:
DrIOS
2024-04-05 16:13:08 -05:00
parent 90b34efa1b
commit d033d7ae1b
9 changed files with 175 additions and 53 deletions

View File

@@ -4,10 +4,10 @@ Import-Module .\output\module\M365FoundationsCISReport\*\*.psd1
<#
$ver = "v0.0.1"
$ver = "v0.1.1"
git checkout main
git pull origin main
git tag -a $ver -m "Release version $ver Minor Update"
git tag -a $ver -m "Release version $ver Bugfix Update"
git push origin $ver
"Fix: PR #37"
git push origin $ver

View File

@@ -0,0 +1,45 @@
function Get-AdminRoleUserLicense {
[CmdletBinding()]
param (
[Parameter(Mandatory = $false)]
[bool]$SkipGraphConnection = $false
)
# Connect to Microsoft Graph if not skipping connection
if (-not $SkipGraphConnection) {
Connect-MgGraph -Scopes "Directory.Read.All", "Domain.Read.All", "Policy.Read.All", "Organization.Read.All" -NoWelcome
}
$adminRoleUsers = @()
$userIds = @()
$adminroles = Get-MgRoleManagementDirectoryRoleDefinition | Where-Object { $_.DisplayName -like "*Admin*" }
foreach ($role in $adminroles) {
$usersInRole = Get-MgRoleManagementDirectoryRoleAssignment -Filter "roleDefinitionId eq '$($role.Id)'"
foreach ($user in $usersInRole) {
$userIds += $user.PrincipalId
$userDetails = Get-MgUser -UserId $user.PrincipalId -Property "DisplayName, UserPrincipalName, Id, onPremisesSyncEnabled"
$adminRoleUsers += [PSCustomObject]@{
RoleName = $role.DisplayName
UserName = $userDetails.DisplayName
UserPrincipalName = $userDetails.UserPrincipalName
UserId = $userDetails.Id
HybridUser = $userDetails.onPremisesSyncEnabled
Licenses = "" # Placeholder for licenses, to be filled later
}
}
}
foreach ($userId in $userIds | Select-Object -Unique) {
$licenses = Get-MgUserLicenseDetail -UserId $userId
$licenseList = ($licenses.SkuPartNumber -join '|')
$adminRoleUsers | Where-Object { $_.UserId -eq $userId } | ForEach-Object {
$_.Licenses = $licenseList
}
}
return $adminRoleUsers
}