user770022
user770022

Reputation: 2959

Add a second line in powershell

I am new to powershell and I am playing around with it.

PS C:\PowerShell> New-Item C:\PowerShell\test.ps1 -type file -force -value "Ping jay"

I want to add Ping google.com below ping jay When I run the script it pings jay which is a pc here then after it completes I want it to ping google.com

Upvotes: 2

Views: 315

Answers (2)

Cole9350
Cole9350

Reputation: 5560

the Semicolon is the line seperator in powershell:

New-Item C:\PowerShell\test.ps1 -type file -force -value "Ping jay ; Ping google.com"

Upvotes: 0

mjolinor
mjolinor

Reputation: 68273

"ping google.com" | add-content C:\PowerShell\test.ps1 

Upvotes: 3

Related Questions