Skip to content
TheChatArchiveThe Chat Archive
gpt-3.5-turbo-0613· OpenAIAi2 WildChat-4.8M (AI2)

Using powershell, run an exe on a remote computer as admin

  1. User

    Using powershell, run an exe on a remote computer as admin

  2. Assistant

    To run an executable on a remote computer as an administrator using PowerShell, you can use the Invoke-Command cmdlet with the -Credential parameter. Here's an example:

    $remoteComputer = "computername"  # Replace with the name or IP address of the remote computer
    $remoteFilePath = "C:\path\to\your\file.exe"  # Replace with the path to the executable on the remote computer
    
    $adminUsername = "Administrator"  # Replace with the admin username
    $adminPassword = ConvertTo-SecureString "adminPassword" -AsPlainText -Force  # Replace with the admin password
    
    $adminCredential = New-Object System.Management.Automation.PSCredential($adminUsername, $adminPassword)
    
    # Command to run the executable on the remote computer as an admin
    $command = {
        param($filePath)
    
        Start-Process -FilePath $filePath -Verb RunAs
    }
    
    Invoke-Command -ComputerName $remoteComputer -FilePath $command -ArgumentList $remoteFilePath -Credential $adminCredential
    

    Please note that you need administrative access on the remote computer, and the specified admin credentials must be valid on the remote computer. Also, make sure to replace "computername", "C:\path\to\your\file.exe", "Administrator", and "adminPassword" with the actual values.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.