$d = 'D ScriptFile'
function ScopeFunction
    {
        Write-Host "Première occurence de D : $((Get-Variable -name d -Scope 2).Value)"
        $d = 'D Function'  # Function scope
        Write-Host "Deuxième occurence de D : $script:d"
        Return [MyClass]::DoSomething()
}

class MyClass
    {
        static [object] DoSomething()
        {
            #return $d  # error, not found dynamically
            #return $script:d # no error
    
            #$e = (Get-Variable -name d -Scope 1).Value
            $e = $script:d
            Write-Warning "E -> $e"
            return $e # no error, found lexically
        }
    }
    #[MyClass]::DoSomething()
ScopeFunction