Start-AsOtherUserAndAdmin.psm1

function Start-AsOtherUserAndAdmin {
    <#
    .SYNOPSIS
    Runs a file as another user with administrative privileges.
 
    .DESCRIPTION
    This function starts a process to run a specified file with elevated permissions as a different user.
 
    .PARAMETER File
    The path to the file that you want to run with elevated permissions.
 
    .NOTES
    Author: Eric Meinders
    Version: 1.0
 
    #>

    [cmdletbinding()]
    param(
        [parameter(Mandatory, Position = 1)]
        [string]$File
    )

    # Start a new PowerShell process with elevated privileges
    Start-Process powershell -Credential (Get-Credential) -ArgumentList "-noprofile -command &{Start-Process '$File' -verb runas}"
}