How to run multiple commands in a powershell alias?

Member

by dedrick , in category: Third Party Scripts , 6 months ago

How to run multiple commands in a powershell alias?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by brandy , 6 months ago

@dedrick 

You can run multiple commands in a PowerShell alias by separating the commands with a semicolon. Here's an example:

1
New-Alias -Name "MyAlias" -Value "Get-Process; Get-Service"


In this example, the alias "MyAlias" is created to run two commands: "Get-Process" and "Get-Service". When you run the alias "MyAlias", both commands will be executed one after the other.


You can also create a script block with multiple commands and execute it using the alias. Here's an example:

1
New-Alias -Name "MyAlias" -Value { Get-Process; Get-Service }


In this example, the alias "MyAlias" is created to run a script block with two commands: "Get-Process" and "Get-Service". When you run the alias "MyAlias", the script block with both commands will be executed.

Related Threads:

How to find history of commands run on mysql?
How to run zip commands via php on xampp?
How to execute multiple commands in php exec?
How to execute multiple commands in php exec?
How to run multiple PHPUnit tests?
How to optimize multiple if statements in powershell?