Test-EntraScript

Checks if the provided script uses Azure AD commands compatible with the Microsoft Entra PowerShell module.

Syntax

Test-EntraScript
    -Path <String[]>
    [-Content <String>]
    [-Quiet]
    [<CommonParameters>]

Description

Checks if the provided script uses Azure AD commands compatible with the Microsoft Entra PowerShell module.

Examples

Example 1

Test-EntraScript -Path .\usercreation.ps1 -Quiet

Returns whether the script usercreation.ps1 could run under Microsoft.Graph.Entra.

Example 2

Get-ChildItem -Path \\contoso.com\it\code -Recurse -Filter *.ps1 | Test-EntraScript

Returns a list of all scripts that wouldn't run under the Microsoft.Graph.Entra module, listing each issue with line and code.

Parameters

-Content

Code content to scan. Used when scanning code that has no file representation (for example, straight from a repository).

Type:System.String
Position:2
Default value:None
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Path

Path to one or more script files to scan. Or name of the content, when also specifying -Content

Type:String[]
Aliases:FullName, Name
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Quiet

Only return $true or $ false, based on whether the script could run under Microsoft.Graph.Entra ($true) or not ($ false)

Type:System.Management.Automation.SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False