Break Down a PowerShell Script Into Multiple Lines

In this blog post, I will show you how to break a PowerShell script to multiple lines.

Sometimes when writing a PowerShell script, there is a need to make the code extra clear and understood.

Backtick

For that reason PowerShell allows us to use a backtick   ` and start a new like of code without breaking our code.

The format to use a backtick is to start with space, backtick and enter.

Blow, is an example of how I break a cmdlet into a few lines.

install-ADDSForest `
-DomainName "corp.ntweekly.com" `
-DomainNetbiosName "ntweekly" `
-SafeModeAdministratorPassword $pass`
-InstallDns:$true `
-NoRebootOnCompletion:$false `
-SysvolPath "C:\Windows\SYSVOL" `
-Force:$true

 

 


Posted

in

by