Powershell – breaking a command down to multilines

So yeah .. I like things to be neat and clean and having a single line command in powershell is the norm for a lot of people.

Example:
New-MailContact -DomainController $dc -Name $alias.ContactName -ExternalEmailAddress $alias.ExternalEmailAddress -Alias $alias.ContactAlias -FirstName $alias.FirstName -Initials '' -LastName $alias.LastName -OrganizationalUnit $OU

But like stated I like things neat(er). So use the ` character at the end of a line to tell Powershell to treat it as the same line.

Example
New-MailContact `
-DomainController $dc `
-Name $alias.ContactName `
-ExternalEmailAddress $alias.ExternalEmailAddress `
-Alias $alias.ContactAlias `
-FirstName $alias.FirstName `
-Initials '' `
-LastName $alias.LastName `
-OrganizationalUnit $OU

Now doesn’t that feel better.

Bookmark the permalink.

Comments are closed.