Create Powershell script from excel

example
hi folks

i like to create a powershell script with multiple lines as you can see in the excel picture above.
How can i write this cells with powershell code from excel to a ps1 file?
Then i like to call this ps1 from excel to execute embedded in vbs code

LaunchPowerShell.VBS
 
Set objShell = CreateObject("Wscript.shell")
 
objShell.run("powershell -noexit -file c:\fso\CleanupFiles.ps1")
LVL 2
Mandy_Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Meir RivkinConnect With a Mentor Full stack Software EngineerCommented:
hi again Mandy.
here's the code:

Private Sub CommandButton1_Click()
Counter = 19
Dim Stringstogether
Do
        Dim Command
        Command = Worksheets("ext2010").Cells(Counter, 2).Value
        Stringstogether = Stringstogether & Command & VbCrLf 
Loop Until Command = ""

Set fso = CreateObject("Scripting.FileSystemObject")

Set oFile = FSO.CreateTextFile(" c:\fso\CleanupFiles.ps1")
oFile.WriteLine Stringstogether 
oFile.Close

Set objShell = CreateObject("Wscript.shell")
 
objShell.run("powershell -noexit -file c:\fso\CleanupFiles.ps1")
End Sub

Open in new window

0
 
Meir RivkinFull stack Software EngineerCommented:
change the counter to the first line where the commands starts.
btw, wouldn't be easier to simple copy all the commands from the excel and create the PS file yourself?
0
 
Mandy_Author Commented:
hi ,

yes what i want is this

Topic

i'm still not have time enough to try different setups. how could i start all commands in only one ps session (EWS) ?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.