title: How to set an executable to run with administrator rights in powershell
body: <p>I need a help </p>
  
  <p>I have trouble to set a script in powershell that give DOMAIN adminsitrator rights to an User to an executable . Because I need to install a program in many desktops, plus I need to check if the program is already installed. </p>
  
  <p>This seams to be easy but I know how to program in shell script not much powershell.</p>
  
  <pre><code>$SPAdmin = "DOMAIN\ADMIN" 
  $Password="FooBoo"|ConvertTo-SecureString -AsPlainText -Force
  $Credential = new-object -typename System.Management.Automation.PSCredential -argumentlist $SPAdmin, $Password 
  
  Get-WmiObject -Class Win32_Service -ComputerName "Server" -Filter "Name='ServiceName'" -Credential $Credential
  
  $name = "CagService"
  
     if (Get-Service $name -ErrorAction SilentlyContinue)
      {   
       Write-Host "O Servico do Agente conhecido como $name ja esta Instalado na Maquina com Hostname: $env:computername"
       sleep 5
      }
      Else
      {
              $storageDir = $pwd
              $source = "https://source"
              $destination = "$storageDir\agent.exe"
  
              Invoke-WebRequest $source -OutFile $destination
  
              $exec = New-Object -com shell.application
              $exec.shellexecute($destination);
      }  
  </code></pre>