I'm putting together a very basic automation script using the windows batch operation in which will loop through a list of IP addresses and run a plink command to logon and keep alive the account on the server because it has recently logged onto the server.
I believe I have most of the function working however I am having an issue with passing through the password. I'm seeing an issue where if the password I have has special characters and in which I run the script through command prompt it does not pass through the special character to the plink command. Here is a look of the script:
@echo on
SET userid=root
SET passwd=Welcome1%
for /f "delims=" %%i in ('type "ipaddress.txt" ') do (
pushd "C:\Program Files (x86)\PuTTY"
plink.exe -pw %passwd% %userid%@%%i hostname
popd
)
The ipaddress.txt file contains:
10.0.0.1
10.0.0.2
10.0.0.3
The idea is to go through the list for each IP address, logon and validate access. I'm also looking to ensure the value Y or N is passed to make sure a server is trusted or not as part of the script. Any help would be greatly appreciated.
set "passwd=Welcome*%%"