Public/Get-PSModuleDependency.ps1

function Get-PSModuleDependency {
    <#
    .SYNOPSIS
    Gets the dependency list for a module.
    .DESCRIPTION
    Returns dependency information for the specified module including direct dependencies,
    total dependency count, and install impact assessment.
    .PARAMETER Name
    The module name.
    .PARAMETER Repository
    The repository. Default is PSGallery.
    .EXAMPLE
    Get-PSModuleDependency -Name "Az"
    #>

    [CmdletBinding()]
    [OutputType([hashtable])]
    param(
        [Parameter(Mandatory, Position = 0)]
        [ValidateNotNullOrEmpty()]
        [string]$Name,

        [string]$Repository = 'PSGallery'
    )

    try {
        $info = Invoke-ProviderGetInfo -Name $Name -Repository $Repository
        if (-not $info) {
            $ErrorActionPreference = 'Continue'
            Write-Error "Module '$Name' not found in repository '$Repository'."
            return $null
        }

        $directDeps = @($info.Dependencies)

        $notInstalled = $directDeps | Where-Object {
            -not (Get-Module -Name $_ -ListAvailable -ErrorAction SilentlyContinue)
        }

        $notInstalledCount = if ($notInstalled) { @($notInstalled).Count } else { 0 }

        $installImpact = if ($notInstalledCount -gt 0) {
            "+$notInstalledCount additional module(s) will be installed"
        } else {
            "All dependencies already installed"
        }

        return @{
            DirectDependencies = $directDeps
            TotalCount = $directDeps.Count
            InstallImpact = $installImpact
        }
    } catch {
        $ErrorActionPreference = 'Continue'
        Write-Error "Get-PSModuleDependency failed for '$Name': $_"
    }
}