I) 40个powershell命令,掌握它们让你成为新一代命令行大神

1.1) URL

URL Resources: https://www.bilibili.com/video/BV1yP411D7ZW/?spm_id_from=333.337.search-card.all.click&vd_source=97ce8e8ec6b926c1293395a04ed185f9

1.2)Basic 40 commands of powershell

1.2.1) get-command

通过这个命令你可以获取当前系统下所有可以使用的命令,这是我们查询命令经常要用到的,当然这里面除了命令以外还包括function,也就是函数,

1.2.1.1)describe
PS C:\Users\Administrator> Describe

cmdlet Describe at command pipeline position 1
Supply values for the following parameters:
Name:
Describe : Cannot bind argument to parameter 'Name' because it is an empty string.
At line:1 char:1
+ Describe
+ ~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Describe], ParameterBindingValidationExce
   ption
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Descr
   ibe
1.2.1.2)mkdir dir_name, rmdir dir_name, ls

LS: List information about the FILEs (the current directory by default).Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.

PS C:\Users\Administrator> mkdir folder_Dec20th2023


    Directory: C:\Users\Administrator


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        12/20/2023   9:30 PM                folder_Dec20th2023

PS C:\Users\Administrator> rmdir .\folder_Dec20th2023\
PS C:\Users\Administrator> ls


    Directory: C:\Users\Administrator


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         12/3/2022  11:22 AM                .android
d-----        12/10/2023   6:12 AM                .codeium
d-----         9/13/2022   5:53 PM                .config
d-----         8/26/2022   6:35 PM                .local
d-----         10/7/2022   3:31 PM                .ssh
d-----          9/1/2022   6:20 AM                .vscode
d-r---         7/24/2022  12:12 AM                3D Objects
d-r---         7/24/2022  12:12 AM                Contacts
d-r---        12/11/2023   4:42 PM                Desktop
d-r---        11/24/2023  11:38 AM                Documents
d-r---        12/20/2023  10:14 AM                Downloads
d-----         9/15/2023   8:47 PM                f
d-r---          9/4/2022   2:27 PM                Favorites
d-r---         7/24/2022  12:12 AM                Links
d-r---         7/24/2022  12:12 AM                Music
d-----         9/15/2023   8:47 PM                o
d-r---         10/8/2022  10:16 PM                Pictures
d-r---         7/24/2022  12:12 AM                Saved Games
d-r---         7/24/2022  12:12 AM                Searches
d-r---        12/19/2022  11:56 AM                Videos
d-----        12/20/2023   8:21 PM                WPS Cloud Files
d-----          9/3/2022   3:16 PM                Yinxiang Biji
-a----        12/23/2022  12:06 PM           3701 .bash_history
-a----         11/8/2022   9:47 PM            104 .gitconfig
-a----         10/9/2022  10:46 PM             20 .lesshst
-a----         7/31/2022   8:35 PM              0 .node_repl_history
-a----         12/1/2022   8:34 PM             41 .npmrc
-a----         9/15/2022   5:47 PM             32 .vuerc
-a----        12/15/2023   4:26 PM             16 a.txt
-a----        12/15/2023   3:27 PM             52 b.txt
1.2.1.3) cd

cd : change directory, needing to follow by a route/path, which does not use individually
PS:
cd / : to root (original disk) path
cd ~ : back to the previous path/route

1.2.1) get-process

get-process这个命令,可以让我们获取当前系统所有正在运行的进程,这个命令有一个别名叫做ps,在cmd中有个tasklist也可以查看所有的进程,当然这个tasklist是一个exe (executive),在powershell中你也可以使用

1.2.1.1) Powershell,get-process, or alias ps
PS C:\Users\Administrator> get-process

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    316      16     2552      13660       0.23   7680   1 360bdoctor
    619      79    64576      31384      41.55    512   1 360rp
    152       8     1456       7124      12.69   2296   0 360rps
    412      43    53920       2648      16.63   2368   1 360sd
   1863     180   219260      38404      88.42   8660   1 360tray
    162      18     3340       4120       0.31  12228   1 360zipUpdate
    974      40    38788     102032      18.59   4504   0 AlibabaProtect

PS C:\Users\Administrator> ps

Handles  NPM(K)    PM(K)      WS(K)     CPU(s)     Id  SI ProcessName
-------  ------    -----      -----     ------     --  -- -----------
    316      16     2552      13660       0.23   7680   1 360bdoctor
    619      79    64576      31384      41.72    512   1 360rp
    152       8     1456       7124      12.77   2296   0 360rps
    410      43    53920       4256      16.70   2368   1 360sd
   1861     180   219404      41304      88.61   8660   1 360tray
    162      18     3340       4120       0.31  12228   1 360zipUpdate
    973      39    38792     102020      18.61   4504   0 AlibabaProtect
    202      12     7248      12804       9.34   8632   0 audiodg
1.2.1.2) cmd: tasklist
C:\Users\Administrator>tasklist

Image Name                     PID Session Name        Session#    Mem Usage
========================= ======== ================ =========== ============
System Idle Process              0 Services                   0          8 K
System                           4 Services                   0        148 K
Registry                        92 Services                   0     80,744 K
smss.exe                       360 Services                   0      1,276 K
csrss.exe                      484 Services                   0      5,556 K
csrss.exe                      580 Console                    1      6,080 K
wininit.exe                    592 Services                   0      7,228 K
services.exe                   648 Services                   0     10,800 K
GitHub 加速计划 / po / PowerShell
44.28 K
7.17 K
下载
PowerShell/PowerShell: PowerShell 是由微软开发的命令行外壳程序和脚本环境,支持任务自动化和配置管理。它包含了丰富的.NET框架功能,适用于Windows和多个非Windows平台,提供了一种强大而灵活的方式来控制和自动执行系统管理任务。
最近提交(Master分支:3 个月前 )
a1774fd9 3 个月前
5ad1f1d2 3 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐