中国DOS联盟

-- 联合DOS 推动DOS 发展DOS --

联盟域名:www.cn-dos.net 论坛域名:www.cn-dos.net/forum
DOS,代表着自由开放与发展,我们努力起来,学习FreeDOS和Linux的自由开放与GNU精神,共同创造和发展美好的自由与GNU GPL世界吧!

中国DOS联盟论坛
现在时间是 2026-08-24 17:43
中国DOS联盟论坛 » WinPE、PowerShell及其它命令行系统专区 » Windows PowerShell的12项酷功能 查看 2,946 回复 7
楼 主 Windows PowerShell的12项酷功能 发表于 2006-11-15 23:23 ·  中国 四川 成都 教育网
铂金会员
★★★★
积分 7,493
发帖 2,672
注册 2005-09-02 00:00
20年会员
UID 42173
性别 男
状态 离线
Windows PowerShell的12项酷功能

Windows PowerShell 1.0已经发布,微软windowsvistablog上,开发人员列举了Windows Vista中Windows PowerShell所提供的12项酷酷的功能:


1. 内置Cmdlets (即"commandlets")
Windows PowerShell中的所有Cmdlets都允许这样的动名词:get-service, get-process, stop-service, get-wmiobject.


2. 强大的通配符和操作对象
要得到以w开头的服务及其依赖服务只要输入:


PS> get-service w* | format-list DisplayName, DependentServices


3. 在犯错误前测试命令
Windows PowerShell 有意向独特的功能:Whatif ,可以不执行命令就告诉你命令执行结果.如:


PS> stop-service w3* -whatif


4. 获取副本
PowerShell 可以开始和结束所有命令的副本,可以在脚本中轻易测试命令并同时保存.


PS> Start-Transcript -Path c:demodfoshow.txt
PS> Stop-Transcript


5. 从命令行发布Windows对话


因为Windows PowerShell位对象而优化,可以向.NET Framework一样从命令行访问COM对象,下列命令告诉你的Vista机器发表"Windows Vista and PowerShell"字串.


PS> $spVoice = new-object -com "SAPI.spvoice"
PS> $spVoice.Speak("Windows Vista and PowerShell")


6. 使用Windows PowerShell访问诸如Windows Media Player 11等的应用程序


PS> $band = "The Posies"
PS> $player = New-object -com wmplayer.ocx
PS> $playlist = $player.mediacollection.getbyauthor($band)
PS> $player.openPlayer($playlist.item(0).sourceurl)


7. Windows PowerShell作为命令行存储计算器
PowerShell可以完成基本的计算工作


PS> 2*2


不过,Windows PowerShell也可以快速解决存储问题,例如,备份11GB的数据需要多少个700MB的CD.


PS> 11gb/700mb


那么,需要多少个1000GB的存储来备份每个320GB,共425个的Vista桌面呢?


PS > (320gb*425)/1000GB


8. PowerShell 用作日历计算


计算多少天到新年:


PS> ("1/1/2007" -::now).days

9. 返回机器上某种类型文件的数量


Windows Vista有许多类型的事件记录和组策略文件等.下列命令是返回当前目录及其子目录中VBScript, Bat 和 PowerShell 脚本的数量:


PS> dir -include *.vbs, *.ps1, *.bat -recurse | group-object extension -noelement


10. 从命令行收集Windows System Assessment Tool数据


PS> get-wmiobject win32_winsat | format-table __SERVER, *SCORE -autosize
PS> get-wmiobject win32_winsat | select *score | out-chart -Title "System Assessment Scores by PowerGadgets"



11. 配置UAC(User Account Control)


PS> set-itemproperty -path HKLM:SOFTWAREMICROSOFTWINDOWSCurrentVersionPoliciesSystem -name ConsentPromptBehaviorAdmin -value 0


12. 管理BitLocker


PS > $drives = get-wmiobject -namespace rootCIMv2SecurityMicrosoftVolumeEncryption -class Win32_EncryptableVolume
PS> $drives | format-table DriveLetter, PersistentVolumeID -autosize
PS> $BitLockDrive = $drives
PS> $BitLockDrive.GetProtectionStatus()
PS> $BitLockDrive.DisableKeyProtectors()
PS> $BitLockDrive.EnableKeyProtectors()


访问:微软windowsvistablog

访问: Windows PowerShell 1.0 发布

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'>"
2 发表于 2006-11-16 01:06 ·  中国 广东 东莞 电信
中级用户
★★
积分 387
发帖 104
注册 2004-11-19 00:00
21年会员
UID 33813
性别 男
状态 离线
功能确实强大,我很喜驱它的导航功能,像注册表中用HKLM:就可进入注册表中的HKEY_LOCAL_MACHINE中去,竟然可以用CD和MD。晕了。哈哈
3 发表于 2006-11-16 03:42 ·  中国 四川 成都 教育网
铂金会员
★★★★
积分 7,493
发帖 2,672
注册 2005-09-02 00:00
20年会员
UID 42173
性别 男
状态 离线
说白了,PowerShell把 Windows Shell Namespace 无私的放到大家面前了,很好!

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'>"
4 发表于 2006-11-16 04:10 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
积分 4,103
发帖 1,744
注册 2006-01-20 13:00
20年会员
UID 49241
性别 男
来自 甘肃.临泽
状态 离线
可以移植到现有的win xp 2003上多好,呵呵~我们先体验体验
5 发表于 2006-11-16 04:52 ·  中国 广东 东莞 电信
中级用户
★★
积分 387
发帖 104
注册 2004-11-19 00:00
21年会员
UID 33813
性别 男
状态 离线
6 发表于 2006-11-16 05:31 ·  中国 甘肃 甘南藏族自治州 合作市 电信
金牌会员
★★★★
积分 4,103
发帖 1,744
注册 2006-01-20 13:00
20年会员
UID 49241
性别 男
来自 甘肃.临泽
状态 离线
Originally posted by zts59 at 2006-11-16 04:52:
有支持XP和2003的,微软官方下载:http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspx

要.NET支持

thanks 我win2003 安装有 .NET Framework 2.0,可以用,呵呵~

[ Last edited by vkill on 2006-11-16 at 05:33 AM ]
7 发表于 2006-11-21 07:41 ·  中国 辽宁 大连 教育网
中级用户
★★
DOS之友
积分 332
发帖 168
注册 2005-10-06 00:00
20年会员
UID 43171
性别 男
来自 天涯
状态 离线
这个一定要试用一下
测试环境: windows xp pro sp2 高手是这样炼成的:C:\WINDOWS\Help\ntcmds.chm
8 发表于 2006-11-22 07:14 ·  中国 湖北 武汉 电信
版主
★★★★★
积分 11,386
发帖 4,938
注册 2006-07-23 17:10
20年会员
UID 59080
状态 离线

  哈哈,我已经用上了,感觉真的不错啊~~

  感谢 est 兄提供的下载链接。
论坛跳转: