You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use Add-MtTestResultDetail to add details from a custom test, but unfortunately it's not working as documented.
I have 3 files in the "custom" folder, all with the same name, a .ps1, .Tests.ps1 and a .md
The test runs as expected and produces the overall status of the test.
I based the logic of the test on your existing tests and used the same logic to add the test details.
These are the files:
.ps1
function Find-RSYUsersMissingManagers {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseSingularNouns', '', Justification = 'Exists is not a plurality')]
[CmdletBinding()]
[OutputType([bool])]
# Retrieve all users from Microsoft Graph
$users = Get-MgUser -All
# Initialize an array to track users without a manager
$usersWithoutManager = @()
$result = $true
# Loop through each user and ensure they have a manager assigned
foreach ($user in $users) {
# Fetch the manager for the current user
$manager = Get-MgUserManager -UserId $user.Id -ErrorAction SilentlyContinue
if ([string]::IsNullOrEmpty($manager)) {
$result = $false
$usersWithoutManager += [PSCustomObject]@{
DisplayName = $user.DisplayName
UserPrincipalName = $user.UserPrincipalName
}
}
}
if ($result -eq $false) {
$TestResults = "There were no users with out Managers assigned. Well Done! :raised_hands:"
}
else {
$TestResults += "Could find managers on:`n`n"
foreach ($u in $usersWithoutManager) {
$TestResults += "- User: $($u.DisplayName) | UPN $($u.UserPrincipalName). :cry:`n"
}
Add-MtTestResultDetail -TestName "Manager Attribute: All users should have a manager attribute set" -Result $TestResults
}
return $result
}
.Tests.ps1
BeforeAll {
. $PSScriptRoot/Find-RSYUsersMissingManagers.ps1
}
Describe "Rothesay" -Tag "Entra", "CustomTests", "AttributeTest" {
It "Manager Attribute: All users should have a manager attribute set" {
$result = Find-RSYUsersMissingManagers
$result | Should -Be $true -Because "All users should have an assigned Manager"
}
}
.md
### This test checks if there are any users without a manager assigned.
##### Custom Rothesay Test
---
<!--- Results --->
%TestResult%
Any help would be appreciated and thank you for creating an amazing utility.
The text was updated successfully, but these errors were encountered:
Hey all,
I'm trying to use Add-MtTestResultDetail to add details from a custom test, but unfortunately it's not working as documented.
I have 3 files in the "custom" folder, all with the same name, a .ps1, .Tests.ps1 and a .md
The test runs as expected and produces the overall status of the test.
I based the logic of the test on your existing tests and used the same logic to add the test details.
These are the files:
.ps1
.Tests.ps1
.md
Any help would be appreciated and thank you for creating an amazing utility.
The text was updated successfully, but these errors were encountered: