In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the PowerShell and Cmd command line example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Commands in PowerShell
Windows PowerShell is a command-line shell and scripting environment that allows command-line users and script writers to take advantage of the power of the .NET Framework. It introduces many new concepts that are very useful, thus further extending the knowledge you have gained and the scripts you have created in the Windows command prompt and Windows Script Host environment
Start PowerShell and enter several commonly used Cmd commands in it
PS D:\ Projects\ Practise\ PowerShell > dir Directory: d:\ Projects\ Practise\ PowerShellMode LastWriteTime Length Name---- Dracheim-1 PM d1dlash23 PM d2-2013 12:35 Amuri-1 alias.txt-a--- 21 alias.txt-a--- 241530 8:38 2013 PM 36314 Grey 1 Meliss2013 8:32 PM 241530
Or
PS D:\ Projects\ Practise\ PowerShell > cd.. PS D:\ Projects\ Practise >
The result was similar to what we expected. But can we just say that PowerShell is PowerShell is an enhanced version of the command line? Try the following command again:
PS D:\ Projects\ Practise\ PowerShell > dir / addir: Cannot find path'd:\ ad' because it does not exist.
...
This is a far cry from our expectations. In Cmd, it should output information about subfolders in the current location, but here, it doesn't seem to understand our parameters. The same goes for the following command:
PS D:\ Projects\ Practise\ PowerShell > fc.\ alias.txt.\ cmdlets.txtFormat-Custom: A positional parameter cannot be found that accepts argument'.\ cmdlets.txt'.
...
I was going to call the fc command to compare two files, but it turned out to be Format- Custom. What's going on? At this point, we can answer the first two questions: PowerShell cannot execute all the commands on the Cmd command line, or rather, PowerShell cannot execute any Cmd commands, at least not directly. This is because PowerShell is not a new or enhanced version of Cmd, it's just that some of its commands are similar to Cmd commands in appearance and function.
The relationship between PowerShell and Cmd command line
PowerShell can be run as an application in Cmd, which is a bit like running SQLCmd or Nslookup in Cmd. It is the running environment of the application until it is clear that exit exits. All input, including commands and data, is accepted and processed by the application.
D:\ Projects\ Practise\ PowerShell > powershell Windows PowerShellCopyright (C) 2012 Microsoft Corporation. All rights reserved.PS D:\ Projects\ Practise\ PowerShell > get-helpTOPIC Windows PowerShell Help System
...
Cmd can also be run as an application in PowerShell, similar to running PowerShell in Cmd:
PS D:\ Projects\ Practise\ PowerShell > cmdMicrosoft Windows [Version 6.2.9200] (c) 2012 Microsoft Corporation. All rights reserved.D:\ Projects\ Practise\ PowerShell > dir / adVolume in drive D is DocVolume Serial Number is A6C5-E7CEDirectory of D:\ Projects\ Practise\ PowerShell 01 PM. 01/30/2013 04:54 PM.. 01On23 PM 2013 12:35 PM d1 01Grey 23 PM D2 …
Through the Alias feature, PowerShell allows users to use PowerShell commands in Cmd style. The advantage of this is that users are as friendly and familiar when they first come into contact with PowerShell as they are using Cmd. The downside is that it makes it easy to confuse PowerShell and Cmd. But when you understand the concept of Alias and the Get-Alias command, the problem will be solved:
PS D:\ Projects\ Practise\ PowerShell > get-alias dir, echo, typeCommandType Name ModuleName-Alias dir-> Get-ChildItem Alias cd-> Set-Location Alias echo-> Write-Output
This means that dir is actually an alias for PowerShell's Get-ChildItem command, and cd is an alias for Set-Location. So far, the problem of the relationship between PowerShell and Cmd is solved.
Will the Cmd command line be replaced by PowerShell?
In fact, I have always hated questions like "who is not as good as who is good" and "who wants to replace whom". It is the same here that new things must have their advantages, and old things also have a lot of fans. From the point of view of the current acceptance of PowerShell, Cmd will not be replaced by PowerShell in a short time. In the long run, who knows. All I know is that one more choice is one more freedom, one more possibility.
Thank you for reading this article carefully. I hope the article "sample Analysis of PowerShell and Cmd Command Line" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.