I want to automate a query that we run manually on networkShell putty by pasting a query from excel sheet into Putty. I have followed the steps :
Open nsh.bat using PowerShell
$wshell = New-Object -com WScript.Shell $wshell.Run("nsh.bat")
After that login to putty using command sendkeys and normally press enter by using "sendkeys" only
I have an Excel sheet where query is pasted in the sheet and I have created a com object of excel and to copy data from the excel sheet
$Excel = New-Object -ComObject Excel.Application $Excel.visible = $true $Workbook = $Excel.Workbooks.Open("Path of excel sheet") $worksheet1 = $Workbook.worksheets.item(1) $worksheet1.activate() $Range = $worksheet1.Range("A1","A38") $Range.Copy()**
Now I want to paste this copied data from excel into Putty(nsh.bat file we have opened) using PowerShell command. Manually we can click mouse right click to paste data into putty but I am unable to paste data using Powershell automatically as Mouse right click is not possible using PowerShell as I couldn't find anywhere. Please help if we can or any way to perform this task.