您最喜欢的 Powershell Cmdlet 是什么?
我刚刚发现 /n 软件免费的 Powershell NetCmdlet,在使用它们之后,我喜欢它们为命令行带来的功能。 因此,这就提出了一个问题:您最喜欢的 Cmdlet 是什么?如何使用它们?
I just found /n softwares free Powershell NetCmdlets, and after playing with them I love the functionality they bring to the command line. So it raises the question what are your favorite Cmdlets, and how do you use them?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(13)
我在整个工作日中使用 Get-WMIObject 和 Get-Member 的组合。 致力于 Get-Sandwich。
The combination of Get-WMIObject and Get-Member is something I use throughout the workday. Working on Get-Sandwich.
我发现 Get-member 是最有用的本机 PowerShell cmdlet。 我还每天使用 Get-WMIObject。 即使我正在为某人解决 VBScript 问题,我也会转向 Get-WMIObject,因为我可以交互地使用 WMI。
I find Get-member to be the most useful native PowerShell cmdlet. I also use Get-WMIObject on a daily basis. Even if I'm troubleshooting a VBScript problem for someone I'll turn to Get-WMIObject because I can work with WMI interactively.
我使用 Microsoft Lync 2010 进行了大量工作,其中包括一组用于测试功能的合成。 其中 Test-CsPstnOutboundCall 是我最喜欢的。
对于一般脚本,必须投票给 get-member 和 get-help :)
I do alot of work with Microsoft Lync 2010 which includes a set of synthetic for testing functionality. Of these Test-CsPstnOutboundCall is my favourite.
For general scripting got to vote for get-member and get-help :)
ls(获取子项)
rm(删除项目)
ps (Get-Process)
和其余我熟悉的命令现在“正常工作”:)
但说真的...... New-Object 必须得到我的投票。 有了它,powershell 可以做任何事情:)
ls (Get-ChildItem)
rm (Remove-Item)
ps (Get-Process)
and the rest of my familiar commands that now "just work" :)
but seriously... New-Object would have to get my vote. With it, powershell can do ANYTHING :)
虽然与您的问题半相关,但它并不完全符合 Powershell NetCmdlets 主题。 但无论如何我想发布它,因为我每天都使用它,它可能会对其他人有所帮助。 只需使用 shift-control-c 组合键即可显示 Visual Studio 命令提示符。
While semi-related to your question, it does not entirely fit the Powershell NetCmdlets motif. But I wanted to post it anyhow as I use it daily and it may help others. Simply making shift-control-c key combo into displaying the visual studio command prompt.
导出 csv。 这将创建一个经理友好的 Excel 格式的精美报告。 如果您安装了社区扩展并使用send-smtpmail,则可获得奖励积分。
从命令行在收件箱中发送管理报告。 好的。
export-csv. This creates a nice report in a manager-friendly Excel-ready format. Bonus points if you have community extensions installed and user send-smtpmail.
Management report in their inbox from the commandline. Nice.
嗯,这有点平淡,但我会投票支持“获取帮助”。
Well it is a little bland, but I would vote for Get-Help.
我编写了一个 PowerShell 提供程序来访问 IE7 的 RSS 提要存储,并从中获得了很多乐趣。
它允许我
cd
到名为feed:
的驱动器,并使用cd
和dir
浏览文件夹和 feed。< br>它甚至允许您从命令行添加或删除提要。
请参阅我博客上的这篇文章作为示例:
在您的 Feed 中获取最多产的作者
如今,它已整合到 PowerShell 社区扩展项目中,您可以在 CodePlex 上找到该项目 此处。
I wrote a PowerShell provider to give me access to IE7's RSS feed store, and had lots of fun with it.
It lets me
cd
to a drive calledfeed:
and navigate around folders and feeds usingcd
anddir
.It even lets you add or remove feeds from the command line.
See this post on my blog as an example:
Getting the Most Prolific Authors in your Feeds
It's rolled up into the PowerShell Community Extensions project nowadays, which you can find on CodePlex here.
虽然它不像 Out-Twitter 那样有趣,但我最喜欢的 cmdlet 是 Get-Member,因为它允许我检查我正在使用的任何对象并找出新的属性和方法,以及该对象的基础类型。目的。
如果我没有选择 Get-Member,我将不得不使用 PowerShell 社区扩展 (PSCX) 中的 Out-Clipboard,因为它支持大量剪贴板自动化,并使使用 PowerShell 进行代码模板化变得更加容易。
While it is not as fun as Out-Twitter, my favorite cmdlet is Get-Member, since it allows me to examine any of the objects I'm working with and find out new properties and methods, as well as the underlying type of the object.
If I did not choose Get-Member, I would have to go with Out-Clipboard from the PowerShell Community Extensions (PSCX), as it enables a whole lot of clipboard automation and makes using PowerShell for code templating much easier.
Set-Clipboard,可在 CodePlex 上的 PowerShell 社区扩展项目中找到。 通常,当我使用 PowerShell 时,最终目标是生成一些文本甚至 Excel 电子表格。 Set-Clipboard 消除了所有中间“将其保存到文件,现在打开该文件,选择全部,复制到剪贴板”的步骤 - 您可以在 PowerShell 中完成这一切。
Set-Clipboard, found on the PowerShell Community Extensions project on CodePlex. Usually when I'm working in PowerShell, the ultimate goal is to generate some text or even an Excel spreadsheet. Set-Clipboard eliminates all of the intermediate "save it to a file, ok now open that file, select all, copy to clipboard" steps--you do it all in PowerShell.
获取会员,放下手来。 不,它不是很迷人,但是交互式检查对象的能力比中断您的工作去访问 MSDN 更好。
Get-Member, hands down. No, it's not very glamorous, but the ability to inspect objects interactively beats interrupting your work to go hit up MSDN.
有一个 out-twitter 脚本 我用来发帖到推特。 这很好,因为这意味着您可以向 Twitter 发送内容,而不必担心被浏览器分心。
我为它添加了一个别名“twit”。
所以现在您可以输入,例如:
如果成功提交,它将返回一个标识您的帖子的整数。
there's an out-twitter script i use for posting to twitter. it's nice, as it means you can send something to twitter without the risk of being distracted by a browser.
i added an alias for it, "twit".
so now you can type, for example:
and if successfully lodged, it will return an integer that identifies your post.
作为一名程序员/黑客,
Get-Member
和Get-Command
是我使用最多的,但我用来炫耀的是Select -Control
和Send-Keys
来自 WASP,PowerGadgets,以及我自己用 WPF 针对 CTP2 或 PoshConsole ;-)As a programmer/hacker,
Get-Member
andGet-Command
are the ones I use more than any others, but the ones I use to show off areSelect-Control
andSend-Keys
from WASP, the PowerGadgets, and some of my own stuff written in WPF against CTP2 or PoshConsole ;-)