Search This Blog

Thursday, December 17, 2015

Multiple PowerShell commands at the same command line

In some situations I want to be able to run 2 or more PowerShell statements on the same line, without using a script (PS1 file).

Semicolon can be used to chain Commands in PowerShell.

powershell -command get-date;get-host

image

This could for example come in handy in a Task Sequence as shown her:

PowerShell -command "&{Import-Module ServerManager;Add-WindowsFeature -Name AS-Ent-Services,AS-Tcp-Port-Sharing,AS-NET-Framework}"

image

No comments:

Post a Comment