Powershell学习笔记

Posted by wsxq2 on 2019-05-10
TAGS:  PowershellTODO

本文最后一次编辑时间:2019-10-12 09:56:27 +0800

重要链接

遇到的问题

rename adapter?

1
PS C:\WINDOWS\system32> Rename-NetAdapter "以太网 5" HostOnly

参见help Rename-NetAdapter

Equivalent of Unix find command on Windows?

1
PS> dir -recurse -ea 0 | % FullName | sls <grep_string>

quick shortcut:

1
2
3
4
5
6
7
8
9
10
PS> function myfind {dir -recurse -ea 0 | % FullName | sls $args }

PS> cd C:\
PS> myfind "Programs" | sls "Microsoft"

#find all text files recursively from current directory
PS> myfind "\.txt$"

#find all files recursively from current directory
PS> myfind .

以上内容来自 linux - Equivalent of Unix find command on Windows - Super User

获取某个命令的路径?(如bash中的which

详情参见 windows - Equivalent of cmd’s “where” in powershell - Super User

使用 Get-Command

1
2
PS C:\Users\alec> (get-command notepad.exe).Path
C:\WINDOWS\system32\notepad.exe

使用 where.exe

1
2
3
4
5
6
7
8
PS C:\Users\alec> where
cmdlet Where-Object at command pipeline position 1
...

PS C:\Users\alec> where.exe
The syntax of this command is:

WHERE [/R dir] [/Q] [/F] [/T] pattern...

添加 Windows 功能?

详情参见 Add or Remove Windows Features Via Command Prompt or PowerShell • Raymond.CC

链接

下面总结了本文中使用的所有链接: