I need to be able to launch command by shell console or powershell having the administrator window in powershell 7.
I have launched several commands with Start-Process but none of them returned the desired value. I was getting back that I needed an interactive screen or just an error.
Start-Process PowerShell -ArgumentList "-noexit","-File", "file url" -verb runas -Wait
Start-Process PowerShell -ArgumentList "-noexit","-File", "file url" -cred credentials -Wait
I also used a function I found, but it doesn't return anything either, it gives me an error that it can't add the line '$startinfo.verb = "RunAs"'.
Function Elevate-Process  {
    param ([string]$arguments)
    $startinfo = New-Object System.Diagnostics.ProcessStartInfo
    $startinfo.FileName = "powershell.exe"
    $startinfo.Arguments = $arguments
    $startinfo.verb = "RunAs"
    $startinfo.UseShellExecute = $false
    $startinfo.CreateNoWindow = $true
    $process = [System.Diagnostics.Process]::Start($startinfo)
}
all of this launched through the Invoke-VMScript