是否可以/如何使用某些cmdlet停止PowerShell? [英] Is it possible to/how do you stop powershell using certain cmdlets?

查看:138
本文介绍了是否可以/如何使用某些cmdlet停止PowerShell?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Powershell显然比cmd更好,但它隐藏了基本功能。我通常使用它来找出如何使用我想在脚本中的命令,但它打破了大量的基本事情,如果我碰到一个粘性的地方,我最终并列使用。

Powershell is clearly a lot better than cmd but it hides basic functionality. I normally use it to figure out how to use commands that I want in scripts but it breaks a large number of basic things and I end up using both side by side if I hit a sticky spot.

今天,这是删除一个目录 - rd或rmdir - 这两个在PowerShell中被破坏,有利于一个它的未记录(从命令行)cmdlet Remove-Item。我似乎遇到它所有的时间,但 - sc(用于服务);当你输入一个命令等时,找到正在被调用的程序。

Today this was removing a directory - rd or rmdir - both of which are broken in powershell in favour of one it's undocumented (from the commandline) cmdlets Remove-Item. I seem to run into it all the time though - sc (for mucking around with services); where for finding what program is being called when you type a command etc etc.

有趣的是我实际上遇到了sc的问题,然后googled找到命令,发现在powershell中没有工作!这是一个令人困惑的一天

Hilariously I actually got the problem with sc and then googled to find out the command where only to discover that didnt work in powershell either! That was a confusing day

在某些情况下,一旦你知道这是怎么回事,你可以键入完整的exe名称(例如'where.exe'其中'在自己的wont)。

In some cases once you know this is what's going on you can type the full exe name (for instance 'where.exe' will work whereas 'where' on its own wont).

然而,这不是rmdir的情况。虽然有趣的是在cmd中输入where rmdirin cmd不起作用。

This isn't the case with rmdir however. Although interestingly typing 'where rmdir' in cmd doesnt work.

所以...我的问题是这是 - 有一种方法关闭

So... my question is this - Is there a way of turning off (preferably all) cmdlets in powershell and just getting the normal stuff instead?

推荐答案

没有必要关闭PowerShell中的cmdlet,因为这会破坏正常的东西

There is no need to turn off cmdlets in powershell as that would destroy the very reason for having it.

大多数正常的东西都是有的,你可以使用 get-alias 命令。

Most of the "normal" stuff is there anyway, which you can find by using the get-alias command.

C:\> get-alias

CommandType     Name
-----------     ----
Alias           % -> ForEach-Object
Alias           ? -> Where-Object
Alias           ?? -> Invoke-NullCoalescing
Alias           ac -> Add-Content
Alias           asnp -> Add-PSSnapin
Alias           cat -> Get-Content
Alias           cd -> Set-Location
Alias           chdir -> Set-Location
.....
..... AND A WHOLE LOT MORE!

如果你缺少一个真正真正想要的命令,新别名:

If you are missing a command that you really, really want to have, then you can easily add a new alias:

Set-Alias python2 "C:\Python27\python.exe"

为了避免每次都这样做,你可以简单地添加到你的启动配置文件。只需在命令提示符下键入 $ PROFILE ,它将显示文件路径。如果它不存在,只需创建它,并且添加到顶部的任何powershell命令将在您开始新会话时自动调用。

In order to avoid having to do this every single time, you can simply add this into your startup profile. Just type in $PROFILE into the command prompt and it will show you the file path. If it doesn't exist, simply create it, and any powershell commands you add to the top will be automatically invoked when you start a new session.

最后一件事。所有的命令都是文档化的,你可以轻松地使用两个。

And last thing. All of the commands are documented, and you can get to them easily using just two.

只需在命令提示符下输入这个命令,就可以进入Powershell启示!

Just type this into your command prompt and you will be on your way to Powershell enlightenment!

get-help get-command

get-command -noun Item
get-command -verb get

这篇关于是否可以/如何使用某些cmdlet停止PowerShell?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆