How to run as username
Posted: 24 May 2011 17:57
I have to find a way to easily verify that hundreds of stations rebooted within the last 24 hours. Unfortunately they do not support PSEXEC so I have to come up with a new script.
With what very limited knowledge I have I found the following script and was able to easily compile and incorporate the IP addresses I need to check, however it only runs correctly for the workstations on my domain. Is there a way I can define what username and password to run it as so that I can run it as the workstations local Admin account?
With what very limited knowledge I have I found the following script and was able to easily compile and incorporate the IP addresses I need to check, however it only runs correctly for the workstations on my domain. Is there a way I can define what username and password to run it as so that I can run it as the workstations local Admin account?
Code: Select all
echo off
:// Give the name of the target computer
Set strComputer=10.11.1.21
for /f "Tokens=2 Delims==" %%i in ('wmic /node:%strComputer% OS Get LastBootUpTime /format:list') Do Set LastBootUpTime=%%i
Set LBT-Year=%LastBootUpTime:~0,4%||: yyy
Set LBT-Month=%LastBootUpTime:~4,2%||: mm
Set LBT-Day=%LastBootUpTime:~6,2%||: dd
Set LBT-Hour=%LastBootUpTime:~8,2%||: hh
Set LBT-Minute=%LastBootUpTime:~10,2%||: mm
Set LBT-Second=%LastBootUpTime:~12,2%||: ss
cls
@echo %strComputer% Last Boot Date= %LBT-Month%/%LBT-Day%/%LBT-Year%>>Lastboot.txt
Set strComputer=10.11.1.22
for /f "Tokens=2 Delims==" %%i in ('wmic /node:%strComputer% OS Get LastBootUpTime /format:list') Do Set LastBootUpTime=%%i
Set LBT-Year=%LastBootUpTime:~0,4%||: yyy
Set LBT-Month=%LastBootUpTime:~4,2%||: mm
Set LBT-Day=%LastBootUpTime:~6,2%||: dd
Set LBT-Hour=%LastBootUpTime:~8,2%||: hh
Set LBT-Minute=%LastBootUpTime:~10,2%||: mm
Set LBT-Second=%LastBootUpTime:~12,2%||: ss
cls
@echo %strComputer% Last Boot Date= %LBT-Month%/%LBT-Day%/%LBT-Year%>>Lastboot.txt
Set strComputer=10.11.1.23
for /f "Tokens=2 Delims==" %%i in ('wmic /node:%strComputer% OS Get LastBootUpTime /format:list') Do Set LastBootUpTime=%%i
Set LBT-Year=%LastBootUpTime:~0,4%||: yyy
Set LBT-Month=%LastBootUpTime:~4,2%||: mm
Set LBT-Day=%LastBootUpTime:~6,2%||: dd
Set LBT-Hour=%LastBootUpTime:~8,2%||: hh
Set LBT-Minute=%LastBootUpTime:~10,2%||: mm
Set LBT-Second=%LastBootUpTime:~12,2%||: ss
cls
@echo %strComputer% Last Boot Date= %LBT-Month%/%LBT-Day%/%LBT-Year%>>Lastboot.txt