Disclaimer 1: This article is not applicable to users who are Domain Admins.

Disclaimer 2: This article suggests to use in your business “push” communication technique, that is not the best practices in asking for feedback.

 

Scenario

Management of ABC Corporation ask Network admin to “open”, based on request, a specific web page on users’ computers. This task has to be launched by a regular user (User1) without Domain admin privileges or local administrator privileges on remote computers. The better option is to run the task on a scheduled time for specified computers with credentials of a Domain User configured as Local Administrators on remote computers.

Script:

PowerShell
Edit|Remove
# Remote Process Execution using PowerShell and PSExec# Author: Valy Greavu, MVP# Date: Nov 2011# Based on Ovidiu P. idea.# Run: .\RemoEx.ps1 -TextFilePath <yourtxtfilepath># Text file must contain all computers one per line#Defining TextFilePath mandatory parameterparam ( 
  [Parameter(Mandatory=$true)][string]$TextFilePath = "." 
  ) 
 
# Defining constant for logFile. You have to change this path.$logFile = "C:\Scripts\Logs\logrem.txt"# Defining the function for logging.function logThis { 
 
        Param ([Parameter(Mandatory=$true)] [string] $logEntry) 
 
        $dt = Get-Date$dt.ToShortDateString() +"-"+$dt.ToShortTimeString() +" | "+$logEntry|Add-Content-Path $logFile 
    } 
 
# Load the list of computers from input text file$Computers = Get-Content$TextFilePath# Parsing the list of computersForEach ($computerin$Computers) { 
 
    logThis "Start procedure for computer name: $computer"# Verify the connection with computer        If (Test-Connection -ComputerName $Computer) {         
        try {  
            logThis "$computer is online."# Defining the remote execution command. # You have to change the psexec.exe path if the file is in another location# Remote process is to open a webpage using default browser on the session of the logged user.$vreCom = "C:\Scripts\PsExec.exe -accepteula \\"+$Computer+" -i -d -e Explorer http://valygreavu.com"#Executing the commandInvoke-Expression$vreCom 
      
            logThis "Invoke is Done!"  
            } 
          
         catch {  
            logThis "Failed: $Computer.Exception.Message"  
            }  
          } 
    Else {  
            logThis "Failed: $Computer is Offline."  
         }       
    } 
      
     logThis "Final of execution for all computers"# EOS

Procedure

  1. Download the script or copy the script text from Technet.
  2. Create a folder Scripts on your drive. Create a Logs subfolder on Scripts.
  3. Fill the list of computers on a text file. If you want to test for your computer only you can use “.” (dot) as computer name.
  4. Download PSTools from https://docs.microsoft.com/en-us/sysinternals/downloads/psexec and copy psexec into your Scripts folder.
  5. Assure that the technical user is local admin on remote computers.
  6. Test the script with a privileged account
  7. On a network server create a scheduled task to run the script with parameters and use technical user as credentials. Be sure that you specify full path for your script.
  8. Test the scheduled task.
  9. Consult log file.
  10. Define your triggers and how to maintain the list of computers.

For video instructions please watch this short video: https://youtu.be/X-HD-CTAbYQ