Sign in to follow this  
Followers 0
nickyyy

Send function only sends the first letter of Variable

2 posts in this topic

Hi Folks,

First post here, tried searching for a solution but couldn't find anything

I am trying to make a script which adds a new user to an AD domain, I have 4 input boxes each with their on variable

$username = InputBox("Enter the new username", "Enter the username")
$firstname = InputBox("Enter the users first name ", "Enter the first name")
$lastname = InputBox("Enter the users last name", "Enter the last name")
$password = InputBox("Enter the users new  password", "Enter the  password", "", "*")
 
what I want to do is parse these variables into a script in a command line window by using this
 
Send("{"& $username&"}") and so on
 
Only the first letter of the variable is actually typed out, for example if I specify the username to be Benjamin it will type out a B
 
Anyone any ideas on how to fix this issue?
 
MsgBox(0, "AD add users", "Let us begin by adding the user to the remote domain!")
Send("{LWIN} powershell")
Send("{ENTER}")
Sleep(1000)
$username = InputBox("Enter the new username", "Enter the username")
$firstname = InputBox("Enter the users first name ", "Enter the first name")
$lastname = InputBox("Enter the users last name", "Enter the last name")
$password = InputBox("Enter the users new  password", "Enter the  password", "", "*")
Sleep(2000)
Send("{"&$username&"} {"&$firstname&"} {"&$lastname&"} {"&$password&"}")
Sleep(10000)
MsgBox(0,"Success", "Script completed successfully, Running on Local AD Server")
Send("{ENTER}")
Send ("C:\Users\Nicky\Desktop\create_ad_users.ps1{ENTER}")
Sleep(1000)
MsgBox(0,"Success", "Script completed successfully, all users have been added")
 

Share this post


Link to post
Share on other sites



Got it! Panic over

For anyone else, I used Send($username) which worked just fine.

Cheers

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0