invoke-command using a PScreds object with the local admin account start-process throw a PSSession using the -Verb runas flag modifying the server B script to "Self elevate", but it still fails from A creating a batch file wrapper with Start-process Is there another way to try that I haven't come up with? When looking for the file in the UNC path, instead of what you're aiming for \login.bat it simply just looks for \.bat. start-process cmd -argument /c c:sersser\desktop\1.cmd test -verb runas # cmd /c start-process c:sersser\desktop\1.cmd -argument test -verb runas # batch by pathext. Connect and share knowledge within a single location that is structured and easy to search. Asking for help, clarification, or responding to other answers. You are basically using a batch file to launch powershell, which launches powershell again which finally tries to run your powershell script. Though Windows PowerShell can be used for a wide range of different applications, for a beginner, the primary utility of PowerShell scripts will be in regard to systems automation related to: Working with batches of files, whether this be to automate backups or to control access to large numbers of files at once. "to be run as an admin". What are some of the best ones? Let's start by addressing the first problem - .PS1 file associations. Create an account to follow your favorite communities and start taking part in conversations. Make the script executable with command chmod +x . 01MDM over 6 years ago. By clicking Accept All, you consent to the use of ALL the cookies. Replacing broken pins/legs on a DIP IC package. Do roots of these polynomials approach the negative of the Euler-Mascheroni constant? Im trying to run this command via a batch file but it gives me an error. These cookies track visitors across websites and collect information to provide customized ads. Step 1 Open the command prompt (cmd.exe). 2 How do I make a PowerShell script run automatically? Necessary cookies are absolutely essential for the website to function properly. https://stackoverflow.com/questions/23618016/use-powershell-variable-in-batch, ============================================.