China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-07-04 21:49
中国DOS联盟论坛 » WinPE、PowerShell及其它命令行系统专区 » [Announcement][Original]Welcome everyone's arrival and initial impression of PowerShell View 5,482 Replies 15
Original Poster Posted 2006-05-01 08:28 ·  中国 上海 闵行区 电信
中级用户
★★
大师兄
Credits 377
Posts 99
Joined 2005-08-26 07:37
20-year member
UID 41945
Status Offline
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 ]
Floor 2 Posted 2006-05-02 18:18 ·  中国 上海 华为云
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
Support
Floor 3 Posted 2006-05-02 18:20 ·  中国 上海 华为云
中级用户
★★
Credits 256
Posts 93
Joined 2006-03-26 22:12
20-year member
UID 52853
Gender Male
From 广东
Status Offline
New command line. Uses objects. Not bad. Just like in the VB family, also uses objects.
Floor 4 Posted 2006-05-02 19:49 ·  中国 湖南 常德 电信
银牌会员
★★★
Credits 1,384
Posts 709
Joined 2005-10-29 22:22
20-year member
UID 44271
Status Offline
Ask the original poster, where can I download PowerShell? I want to learn it, just not too difficult, heh.
Floor 5 Posted 2006-05-02 20:35 ·  中国 上海 闵行区 电信
中级用户
★★
大师兄
Credits 377
Posts 99
Joined 2005-08-26 07:37
20-year member
UID 41945
Status Offline
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 ]
Floor 6 Posted 2006-05-02 21:04 ·  中国 湖南 常德 电信
银牌会员
★★★
Credits 1,384
Posts 709
Joined 2005-10-29 22:22
20-year member
UID 44271
Status Offline
So it's still in testing, then just wait first.
Floor 7 Posted 2006-05-03 21:46 ·  中国 四川 成都 电信
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
Support~~~~It's too much like Bash~~
Floor 8 Posted 2006-06-09 08:12 ·  中国 浙江 杭州 电信
荣誉版主
★★★★
batch fan
Credits 5,226
Posts 1,737
Joined 2006-03-10 00:38
20-year member
UID 51697
From 成都
Status Offline
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.
Floor 9 Posted 2006-07-13 07:44 ·  中国 辽宁 大连 教育网
中级用户
★★
DOS之友
Credits 332
Posts 168
Joined 2005-10-06 00:00
20-year member
UID 43171
Gender Male
From 天涯
Status Offline
Hehe, not needed for the time being. Many commands, the current machines should not support. That support object is really very good
Floor 10 Posted 2006-07-31 13:11 ·  中国 广东 深圳 宝安区 电信
高级用户
★★★
Credits 793
Posts 312
Joined 2004-09-02 00:00
21-year member
UID 31104
Gender Male
Status Offline
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 ]
Floor 11 Posted 2006-10-06 09:29 ·  中国 浙江 湖州 电信
中级用户
★★
Credits 301
Posts 74
Joined 2005-02-25 00:00
21-year member
UID 36491
Gender Male
Status Offline
The help file of Windows PowerShell is not used, so Windows PowerShell is not used
Floor 12 Posted 2006-10-08 05:44 ·  中国 四川 成都 教育网
铂金会员
★★★★
Credits 7,493
Posts 2,672
Joined 2005-09-02 00:00
20-year member
UID 42173
Gender Male
Status Offline
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

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>"
Floor 13 Posted 2006-10-08 06:18 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Bump first``
The command prompt function of the next generation is more powerful, supporting~~~
Floor 14 Posted 2007-04-25 10:54 ·  中国 湖北 黄冈 电信
高级用户
★★★
Credits 894
Posts 411
Joined 2007-02-17 12:15
19-year member
UID 79697
Gender Male
Status Offline
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.
@set c= 不知则觉多,知则觉少,越知越多,便觉越来越少. --- 知多少.
@for,/l,%%i,in,(1,1,55)do,@call,set/p=%%c:~%%i,1%%<nul&ping/n 1 127.1>nul


Floor 15 Posted 2007-04-28 18:12 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
19-year member
UID 59080
Status Offline
Oh, just download .NET first and then install PowerShell. You don't need to worry about .NET; PowerShell can be used directly.
Forum Jump: