I am trying to make a .bat file I am trying to run powershell in it so I can run psexec to open cmd.exe in a another computer to do a gpupdate /force. I am trying to have them prompt to enter the computer number and then psexec would run with that computer number
I have the following so far but its not working. I am needing help...
echo Please Run As Your Admin Account
cls
pause
Powershell
echo please type in computer name
echo %computername%
pause
powershell -command "C:\utilities\pstools\psexec.exe" \\%computername&\ cmd.exe
gpupdate /force
exit
Thanks
Needing Help Creating a .bat file with Powershell Incorporated
Moderator: DosItHelp
Re: Needing Help Creating a .bat file with Powershell Incorporated
Why do you think you need to use Powershell to do this. You can just run PSEXEC by itself.
Your gpupdate command will only run on the local computer. If want it to run on a remote computer then you will need to use PSEXEC for that as well.
Your gpupdate command will only run on the local computer. If want it to run on a remote computer then you will need to use PSEXEC for that as well.
Re: Needing Help Creating a .bat file with Powershell Incorporated
I assumed I needed power shell for that. so when I run the psexec command.exe it opens a new window but the computer number doesnt populate. Do you know what the code would be or what I need to write to fix it?
Re: Needing Help Creating a .bat file with Powershell Incorporated
So how would I make the script to run psec to do a gpupdate? I want it to have them enter the computer number and with that the cmd.exe will open to that specific computer number and run the gpupdate
Re: Needing Help Creating a .bat file with Powershell Incorporated
You should probably take a step back and learn to use the commands first before trying to put them into a batch file.
Can you get PSEXEC to work by manually running it from the cmd prompt?
Your PSEXEC code example does not use any user name or password. Usually when you are trying to connect to a remote computer that is going to require credentials. If the user name and password of the computer you are using is not the same on the remote computer then you need to provide the username and password with PSEXEC.
Can you get PSEXEC to work by manually running it from the cmd prompt?
Your PSEXEC code example does not use any user name or password. Usually when you are trying to connect to a remote computer that is going to require credentials. If the user name and password of the computer you are using is not the same on the remote computer then you need to provide the username and password with PSEXEC.
Code: Select all
psexec \\remotepc -u Squashman -p Password gpudate