PowerShell Tip: Never Leave the Console for OS Commands

PowerShell Tip: Never Leave the Console for OS Commands

Here's something you may not be aware of. Did you know that the majority of OS commands can be run directly from within the PowerShell window?

In the past, when utilizing another scripting language you would have write code to pipe out to the CMD shell to run commands designed to be run in a simulated DOS prompt. This included any 3rd party utilities and also commands that come with the OS.

PowerShell runs on top of the underlying OS allowing you to use most commands within the same window. This can save a lot of time, keeping you from having to jump back and forth between PowerShell and a CMD prompt. It can also save a lot of code lines since PowerShell recognizes and executes common commands. For the following example, I just use the simple Xcopy command to transfer files from one directory to another.

Give it a shot and have fun. Obviously, there are reserved words in PowerShell that are tied to the scripting language. An example of this is the Windows environment SET command. In a normal CMD window, the SET command will produce the list of OS environment variables such as the locations for the \Temp and \SystemRoot directories. In PowerShell, the SET command is used to assign variables used in PowerShell scripts.

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish