中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-24 20:16
47,812 topics / 349,910 posts / today 1 new / 48,262 members
WinPE、PowerShell及其它命令行系统专区 » [Announcement][Original]Welcome everyone's arrival and initial impression of PowerShell
Printable Version  5,687 / 15
Floor1 tigerpower Posted 2006-05-01 08:28
中级用户 Posts 99 Credits 377
This place has just been established, welcome everyone's arrival!

Since it's just the May Day holiday, I估计 there won't be time to write articles in the next few days, but I don't want this place to be empty, so I'll first briefly chat with you about PowerShell.

First, I would like to state that if you are a beginner, you may not fully understand what I'm going to say below, or you are completely a layman in the command line but are very interested in it, then please pay close attention to our forum section. We will compile step-by-step tutorials for beginners so that they can gradually master and use it. The specific writing work of the tutorials will be carried out gradually after the holiday.
Please look forward to it!

PowerShell is Microsoft's next-generation Windows command-line tool. It is a brand-new command line. I roughly read its man page and simply tried a few commands. The strongest feeling I have is "the usage of this new tool is too similar to Python" (Python is an object-oriented scripting language).

We know that traditional shells - such as cmd.exe in Windows XP, its input and output are all text. When we use pipes or redirection to connect several commands, what we pass are all text. But PowerShell is completely different from this. Its input and output are all objects. You may not have object-oriented programming experience. It doesn't matter. Let's first look at a few examples:
Today is May 1, 2006. I only want the year now. In cmd.exe, we can

C:\> echo %date:~0,4%
2006

Use the slicing method to get the first 4 characters. But there is a problem with this method. That is, other ethnic groups may use the writing habit of month/day/year like 05/01/2006. So when the "Regional and Language Options" setting of the system is different, the first 4 characters of the variable date may not necessarily be the year.

But the way in PowerShell is:

PS C:\> ::now.year
2006

is an object with the property now, and now itself has the property year. (Properties are actually similar to variables)
So we get the year in the above way.

If we want to get yesterday's date, in PowerShell:

PS C:\> ::now.adddays(-1)
April 30, 2006 7:29:00

Only the month in yesterday's date:

PS C:\> ::now.adddays(-1).month
4

adddays is called a method of now (methods are actually similar to functions)
If we want to save this month in a variable for future use:

PS C:\> $yestoday=::now.adddays(-1).month
PS C:\> $yestoday
4

If cmd under Windows XP wants to do the same thing (assuming no third-party software is used), generally first slice the year, month, and day into variables respectively, and then write the algorithm by yourself. Since it is necessary to consider that there are 28 days, 30 days, 31 days in a month, and also consider leap years, the algorithm is not very simple.


Maybe you will ask, what exactly are properties and methods, and how should they be used?
Let's take an example: Boy Xiaoming is the sports committee member, Girl Xiaoling is the monitor
Xiaoming, as an object, has the attribute gender, and the value of this attribute is male.
Xiaoming.gender ->male
So when "Xiaoming.gender" appears in the command line, the system will automatically calculate "male".
Similarly, we can use "Xiaoling.name", and the system will automatically calculate "Xiaoling".
Since Xiaoling is the monitor, she can send the instruction "stand up" during class breaks. So Xiaoling has the method "stand up". Using this method will result in all classmates standing up.
Xiaoling.stand up() ->All classmates stand up

For example, convert "this is a string" to uppercase

PS C:\> "this is a string".ToUpper()
THIS IS A STRING

As long as it is a string, it must have the ToUpper() method.
"this is a string".ToUpper() still returns a string object, and we can continue to use the methods of the string.

PS C:\> "this is a string".ToUpper().ToLower()
"this is a string"

That's all for talking about PowerShell today.

[ Last edited by tigerpower on 2006-5-2 at 12:50 ]
Floor2 doscc Posted 2006-05-02 18:18
中级用户 Posts 93 Credits 256 From 广东
Support
Floor3 doscc Posted 2006-05-02 18:20
中级用户 Posts 93 Credits 256 From 广东
New command line. Uses objects. Not bad. Just like in the VB family, also uses objects.
Floor4 wl00560 Posted 2006-05-02 19:49
银牌会员 Posts 709 Credits 1,384
Ask the original poster, where can I download PowerShell? I want to learn it, just not too difficult, heh.
Floor5 tigerpower Posted 2006-05-02 20:35
中级用户 Posts 99 Credits 377
To install Windows PowerShell, you need:
1. An operating system of Windows XP/2003/Vista
2. .NET Framework Version 2.0 RTM

Microsoft officially released the Windows PowerShell preview version (RC1) on April 25, 2006, and its final official version is expected to be released in the fourth quarter of this year.
Click to enter the Windows PowerShell RC1 download page (registration required)

There is a link to the PowerShell help documentation ("Windows PowerShell RC1 Documentation Pack") on the same page
And a link to .NET Framework Version 2.0 RTM ("More .NET Framework Downloads")
In addition to the 32-bit version, it also has x64 and ia64 versions.

[ Last edited by tigerpower on 2006-5-2 at 20:58 ]
Floor6 wl00560 Posted 2006-05-02 21:04
银牌会员 Posts 709 Credits 1,384
So it's still in testing, then just wait first.
Floor7 electronixtar Posted 2006-05-03 21:46
铂金会员 Posts 2,672 Credits 7,493
Support~~~~It's too much like Bash~~
Floor8 namejm Posted 2006-06-09 08:12
荣誉版主 Posts 1,737 Credits 5,226 From 成都
Today I just saw the usage of Microsoft's next-generation command line, and I feel this tool is really powerful - I don't know if the next version of the operating system will still support all cmd commands in XP.
Floor9 IceCrack Posted 2006-07-13 07:44
中级用户 Posts 168 Credits 332 From 天涯
Hehe, not needed for the time being. Many commands, the current machines should not support. That support object is really very good
Floor10 willsion Posted 2006-07-31 13:11
高级用户 Posts 312 Credits 793
Powerful function, not bad.

It feels a bit like the "structure" part of the C language.

[ Last edited by willsion on 2006-7-31 at 13:20 ]
Floor11 shayulei Posted 2006-10-06 09:29
中级用户 Posts 74 Credits 301
The help file of Windows PowerShell is not used, so Windows PowerShell is not used
Floor12 electronixtar Posted 2006-10-08 05:44
铂金会员 Posts 2,672 Credits 7,493
I have the same feeling as the person above. But now Power Shell has become a part of Microsoft Script Center, which is enough to show the importance of PowerShell
Floor13 lxmxn Posted 2006-10-08 06:18
版主 Posts 4,938 Credits 11,386
Bump first``
The command prompt function of the next generation is more powerful, supporting~~~
Floor14 6622186 Posted 2007-04-25 10:54
高级用户 Posts 411 Credits 894
I downloaded it, but it also requires .NET support. The .NET is 22MB. After looking at the help, I didn't understand it. It was about objects and aliases. Then somehow the .chm file couldn't be opened by restricted users, so I uninstalled the .NET.
Floor15 lxmxn Posted 2007-04-28 18:12
版主 Posts 4,938 Credits 11,386
Oh, just download .NET first and then install PowerShell. You don't need to worry about .NET; PowerShell can be used directly.
1 2  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023