Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've done a fair bit of programming in C#, but then I've also written a lot of T-SQL scripts. C# requires semicolons, and T-SQL and PowerShell they're optional. What do you do for PowerShell? Why? My gut feel is to include semicolons but I don't know why.

share|improve this question

closed as not constructive by Sven, mulaz, Brent Pabst, MadHatter, Scott Pack Oct 29 '12 at 16:38

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

    
Are you talking about semicolons to end the line? this question is offtopic. –  Hex Oct 29 '12 at 12:07
    
@Hex: Why would it be off topic? PowerShell is used to administer you machine, so why not... –  Bart De Vos Oct 29 '12 at 13:14
    
@Hex Yes at the end of a line. Why is it off-topic? –  Mark Allison Oct 29 '12 at 13:52
    
Mark Allison, sorry it was my mistake because I misunderstood your question. In linux powershell you do not need to add semicolons same as you dont need to add semicolons in MS DOS. –  Hex Oct 29 '12 at 14:54

2 Answers 2

up vote 11 down vote accepted

Powershell primarily uses new lines as statement seperators, but semicolons may be used for multiple statements on a single line.

share|improve this answer

The key, no matter whether you choose to use semicolons or not, is to be consistent. If you are used to using them in C#, then continue to use them in PowerShell. If you don't want to use them, then don't use them. Pick a standard and stick with it for you and the people that will read and use your code. It will get ugly if you decide halfway through a project to start using them.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.