@ECHO OFF REM Get username and password from user's input set var1=%1 set var2=%2 REM Don't allow user to change password NET USER %var1% %var2% /add /expires:never /passwordchg:no REM User's password never expire wmic useraccount where "Name='%var1%'" set Passwordexpires=false REM Add user to remote desktop group NET localgroup "Remote Desktop Users" %var1% /add REM Create … Continue reading Create_User.bat
Tag: Batch Script
WMIC Examples
I did not get many chances to use WMIC (Windows Management Instrumentation Command-line) before, but recently I have used it twice and found it is really handy! Example 1: Get local user SID wmic useraccount get name,sid Example 2: Set a local user’s password never expire wmic useraccount where "Name='user01'" set Passwordexpires=false
ESXi 5.0 Host Backup Script
I wrote up a batch script to backup the ESXi 5.0 host configuration every night, email the backup report and remove the old archive folders that is older than 7 days. To make it work, you need to: 1) install the vCLI and add its bin folder to the system PATH 2) Add all your … Continue reading ESXi 5.0 Host Backup Script
Batch Script: Send Email
sendmail is a handy tool that can be used in batch script to send email. 1) Configure your SMTP settings in the sendmail.ini file. Following is a sample to use Gmail: [sendmail]; you must change mail.mydomain.com to your smtp server,smtp_server=smtp.gmail.com ; smtp port (normally 25)smtp_port=465 ; error logerror_logfile=mail_error_log.txt ; Gmail username and passwordauth_username=xxxxxx@gmail.comauth_password=*********** ; the … Continue reading Batch Script: Send Email
Batch Script: Install SCOM Agent on Non-Domain Servers
I wrote a script to install the scom agent on some DMZ servers. Those servers are not in domain, so I have to request certificates from a stand alone server for them. SCOM-01 is both the SCOM server and the stand alone server. 32 bits: install32.bat @ECHO OFF REM SCOM INSTALLATION SCRIPT FOR /F "tokens=1-3" … Continue reading Batch Script: Install SCOM Agent on Non-Domain Servers