Link to home
Start Free TrialLog in
Avatar of Mandy_
Mandy_

asked on

Open Powershell (EMS) command within VBA Excel

hi folks,

could anybody help me to execute the powershell command in excel?
In every excel row is stored a command until "".  Is it also possible to
excecute every command in only one powershell session?



Private Sub CommandButton1_Click()
Counter = 4
Do
       Dim Command
       Command = Worksheets("user").Cells(Counter, 4).Value

Shell ("C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit icm -ScriptBlock {"& Command & "})" ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1';Connect-ExchangeServer -auto;"
'-noexit icm -ScriptBlock {"&Command&"})


Counter = Counter + 1
Loop Until Command = ""
End Sub

Open in new window

Avatar of Vijaya Babu Sekar
Vijaya Babu Sekar
Flag of India image

if your coding will be .ps1 format. you can store it as .ps1 and you can run it through powershell with single session.


Thanks.
Avatar of Mandy_
Mandy_

ASKER

here you see the picture . the commands should execute line by line until an empty line

User generated image
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mandy_

ASKER

What should i say, again a masterpiece....

thank you so much