I want to be able to have the user input just the last octet of the IP address to run GPUPDATE on, to use as the IP. What is written doesn't work and not sure how to set it up. If anyone has any other useful tools to incorporate, I'd greatly appreciate it!
See code
@echo off color C title Multiple Choice Menu :home cls echo. echo ============= echo Select an IA task: echo ============= echo. echo 1) See Who's Logged On echo 2) Run Remote GPUPDATE echo 3) Exit echo. set /p web=Type option: if "%web%"=="1" goto psloggedon if "%web%"=="2" goto GPUPDATE if "%web%"=="3" exit goto home
:GPUPDATE set /p UserInput1= What IP Address would you like to run GPUPDATE on 192.168.1.? psexec \\192.168.1.%UserInput1% gpupdate /force Pause goto home
:psloggedon set /p UserInput2= What IP address would you like to search? psloggedon \\%UserInput2% pause goto home
What versions of Windows are you working with? If on Win 8 or Server 2012 and up achieving this with PowerShell would likely be a better solution with the Invoke-GPUpdate command included in the Active Dirtectory PowerShell Cmdlets.
This is a crude example, but you get the idea:
$IP = Read-Host -Prompt "What is the IP address?"
$User = Read-Host -Prompt "What is the user account?"
Invoke-GPUpdate -computer $IP -Target $User
Well, you can definitely create menu scripts with PoSH. I'd really recommend learning it, even if not for this mini-project. Microsoft now treat PoSH as a first class citizen, often it leads GUI options in MS products so you have to use it to get certain tasks done.
Not to mention it really is the only way to initially manage Server Core and Nano Server installations.
I don't really know much PoSH but I can pick my way through. I learned the basics from the PowerShell in a Month of Lunches books and Youtube Videos. It's a very good starting place.
Just a thought, your syntax looks fine, but you might need to preceed the psexec command with a runas command to set the account that will execute the psexec?
Does your menu script work as expected against the local machine you are running it on?