Test-EntraScript not in v1.0.1
Describe the bug
I installed the newest Microsoft.Entra Module bundle (version 1.0.1), but the cmdlet Test-EntraScript is not available. According to the documentation it should be included.
Docs:
https://learn.microsoft.com/en-us/powershell/entra-powershell/migration-guide?view=entra-powershell&wt.mc_id=MVP_330618#test-compatibility-with-test-entrascript-command
https://learn.microsoft.com/en-us/powershell/module/microsoft.entra/test-entrascript?view=entra-powershell&wt.mc_id=MVP_330618
Error message:
Test-EntraScript: The term 'Test-EntraScript' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
To Reproduce Steps to reproduce the behavior:
- Install Microsoft.Entra
- Run
Test-EntraScript(not working) - Run other Cmdlets from the module e.g.
Connect-Entra(working)
Expected behavior The cmdlet should be included in the module
Debug Output not applicable
Module Version
PS C:\> Get-Module Microsoft.Entra*
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Manifest 1.0.1 Microsoft.Entra
Script 1.0.1 Microsoft.Entra.Applications {Add-EntraApplication…
Script 1.0.1 Microsoft.Entra.Authentication {Add-EntraEnvironment…
Script 1.0.1 Microsoft.Entra.DirectoryManagement {Add-EntraAdministrat…
Script 1.0.1 Microsoft.Entra.Governance {Enable-EntraAzureADA…
Script 1.0.1 Microsoft.Entra.Groups {Add-EntraGroupMember…
Script 1.0.1 Microsoft.Entra.Reports {Enable-EntraAzureADA…
Script 1.0.1 Microsoft.Entra.SignIns {Enable-EntraAzureADA…
Script 1.0.1 Microsoft.Entra.Users {Enable-EntraAzureADA…
Environment Data
PS C:\> $PSversiontable
Name Value
---- -----
PSVersion 7.4.6
PSEdition Core
GitCommitId 7.4.6
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Screenshots
Additional context none
It doesn't appear that the Microsoft.Entra module has any cmdlets or functions whatsoever:
The Test-EntraScript function isn't mapped into the build process for the Microsoft.Entra module yet and therefore doesn't get delivered in the published build. (I don't know why, but the 'Migration' category that this is tagged in is specifically skipped.)
However, it does still exist in a standalone form that you can download (Test-EntraScript) and is also still in the legacy build of the Microsoft.Graph.Entra module.
Thank you, @SamErde. I tried your suggestion of running the module manually. Do we know what the expected output is? I only tested with one script, but didn’t get any output. Then I tried with the -Quiet parameter and received $false.
I would assume some sort of output when not using -Quiet to tell me what issues exist within the script.
The purpose of that specific function is only to: "check whether the provided script is using AzureAD commands that are not supported by Microsoft.Graph.Entra."
Per the function's help, the Quiet parameter hides the test output and only returns true or false as a result of the check. In this case, false should indicate that the script you tested does not use any unsupported commands.
In addition to the documentation that you referenced earlier, there is a lot of useful information to be learned just by opening the script and reading the comment based help. 😀
<#
.SYNOPSIS
Checks, whether the provided script is using AzureAD commands that are not supported by Microsoft.Graph.Entra.
.DESCRIPTION
Checks, whether the provided script is using AzureAD commands that are not supported by Microsoft.Graph.Entra.
.PARAMETER Path
Path to the script file(s) to scan.
Or name of the content, when also specifying -Content
.PARAMETER Content
Code content to scan.
Used when scanning code that has no file representation (e.g. straight from a repository).
.PARAMETER Quiet
Only return $true or $false, based on whether the script could run under Microsoft.Graph.Entra ($true) or not ($false)
.EXAMPLE
PS C:\> Test-EntraScript -Path .\usercreation.ps1 -Quiet
Returns whether the script "usercreation.ps1" could run under Microsoft.Graph.Entra
.EXAMPLE
PS C:\> Get-ChildItem -Path \\contoso.com\it\code -Recurse -Filter *.ps1 | Test-EntraScript
Returns a list of all scripts that would not run under the Microsoft.Graph.Entra module, listing each issue with line and code.
#>
Test-EntraScript needs to be added to all sub-modules and shipped as part of the sub-modules.
In addition to the documentation that you referenced earlier, there is a lot of useful information to be learned just by opening the script and reading the comment based help. 😀
From the description of -Quiet:
"Only return $true or $ false, based on whether the script could run under Microsoft.Entra ($true) or not ($ false)"
That means that the script is not supported when returning $false. However, I wish I understood why it's not supported when running it without the -Quiet parameter. What cmdlets are causing the compatibility issue?