• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 46
  • Last Modified:

What is the correct powershell command?

This is using MS Windows Server 2012 R2. I want to run a powershell command in task scheduler, so I do a testing in the command prompt. My server has 4 NICs, namely, Embedded LOM 1 port 1/2/3/4. I intend to restart nic 2 (embedded lom 1 port 2), so i tried the commands as follows:

       powershell -command {get-netadapter}        WORKED
       powershell -command {restart-netadapter -name embedded lom 1 port 2}          FAILED
       powershell -command {restart-netadapter -name "embedded lom 1 port 2"}       FAILED
       powershell -command &{restart-netadapter -name embedded lom 1 port 2}       FAILED
       powershell -command "& {restart-netadapter -name embedded lom 1 port 2}     FAILED
       powershell -command "& {restart-netadapter -name "embedded lom 1 port 2"}   FAILED

What is the correct command?
1 Solution
powershell.exe -command "Restart-NetAdapter -Name 'Embedded LOM 1 Port 2'"

Open in new window

MichaelBalackAuthor Commented:
Thanks for expert-oBdA, this command works like a charm.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now