What I am looking to do seems fairly simple but I cant figure it out. I am looking to run a Powershell script to launch an RDP session, copy a file to the c:\ directory, then run that file from a command line. I would like it to loop, getting the paramaters froma csv file, such as server IP, username, and password. So in essence the steps would be as follows...
1.import infor from the csv file to define variables
2.copy specefied file (then loop)
3.launch mstsc.exe
4.enter server IP, username, password
5.paste copied file into the c:\ directory
6.launch cmd.exe
7.Run the file that was copied to the c:\ directory
8.log off server
I wanted to see if someone could help me out with this.I am new to power shell and have been able to work through a lot of it. If someone could point me in the right direction, or even provide me the code to fill in the blanks, I would greatly appreaciate it.
To be more spacific as to what I am trying to do is install an agent onto a machine. The process would entail logging onto a server via rdp, running a silent install (msi) package from a command line and thats it. What I would like to do is provide a spreadsheet to my client and have him fill out the details, such as server address, username, and password. The I and turn to a csv, run the powershell, and install many of the agents via that script, sort of an automated process in essence. Hope that explains it a little better.
Here is what I have so far...
Windows....
$computers= gc "C:\Users\Desktop\Powershell\DeviceList.txt"
foreach ($computername in $computers)
{
mstsc
Start-Sleep -s 2
[System.Windows.Forms.SendKeys]::SendWait("$computername{ENTER}")
That will only launch the mstsc session, so its only a piece of the puzzle, what I need to do then is copy a file to that device and then run cmd.exe and a single command and log out.
For UNIX>>>
$computers= gc "C:\Users\Desktop\Powershell\DeviceList.txt"
foreach ($computername in $computers)
{
c:\putty.exe
Start-Sleep -s 2
[System.Windows.Forms.SendKeys]::SendWait("$computername{ENTER}")
}
Pretty much the same thing, but I can run commands directly from putty to make this work and do not have to copy a file as I can get it another way by running a few commands.
Any help or ideas with this is appreaciated, thanks.