Ask Your Question
3

Is it possible to make the "&" or "-and" commands function in PowerShell?

asked 2023-02-25 11:00:00 +0000

djk gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-09-04 06:00:00 +0000

devzero gravatar image

Yes, it is possible to use the "&" or "-and" commands in PowerShell to perform logical AND operations.

For example, to check if both conditions are true:

if ($a -eq "Yes" -and $b -eq "No") {
  Write-Host "Both conditions are true"
}

Similarly, to run multiple commands in sequence using "&":

& command1
& command2

Or using "-and":

command1 -and command2
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-02-25 11:00:00 +0000

Seen: 10 times

Last updated: Sep 04 '21