PowerShell 技能连载 - 最常用的动词

让我们来看看您的 PowerShell 中哪个命令动词是最常用的:

1
2
3
Get-Command -CommandType cmdlet, function |
Group-Object -Property Verb |
Sort-Object -Property Count -Descending

这是我们系统的输出结果:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
Count Name                      Group
----- ---- -----
456 Get {Get-AppBackgroundTask, Get-AppvVirtualProcess...
210 Set {Set-AssignedAccess, Set-AutologgerConfig, Set...
120 Remove {Remove-AutologgerConfig, Remove-BCDataCacheEx...
102 New {New-AutologgerConfig, New-DAEntryPointTableIt...
72 Enable {Enable-BCDistributed, Enable-BCDowngrading, E...
70 {A:, ABC, AfterAll, AfterAll...}
67 Add {Add-BCDataCacheExtension, Add-BitLockerKeyPro...
65 Disable {Disable-BC, Disable-BCDowngrading, Disable-BC...
28 Start {Start-Animation, Start-AppBackgroundTask, Sta...
26 Update {Update-Disk, Update-DscConfiguration, Update-...
24 Clear {Clear-AssignedAccess, Clear-BCCache, Clear-Bi...
22 Export {Export-Application, Export-BCCachePackage, Ex...
22 Invoke {Invoke-AsWorkflow, Invoke-Background, Invoke-...
20 Import {Import-BCCachePackage, Import-BCSecretKey, Im...
19 Stop {Stop-DscConfiguration, Stop-Dtc, Stop-DtcTran...
19 Rename {Rename-DAEntryPointTableItem, Rename-MaskingS...
19 Test {Test-Ancestor, Test-Descendent, Test-Dtc, Tes...
16 Register {Register-ClusteredScheduledTask, Register-Dns...
15 ConvertTo {ConvertTo-DataTemplate, ConvertTo-GridLength,...
14 Write {Write-DtcTransactionsTraceSession, Write-Prin...
14 Show {Show-Clock, Show-Details, Show-NetFirewallRul...
14 Reset {Reset-BC, Reset-DAClientExperienceConfigurati...
13 Unregister {Unregister-AppBackgroundTask, Unregister-Clus...
11 Out {Out-GridViewVertical, Out-Notepad, Out-Voice,...
11 Copy {Copy-DependencyProperty, Copy-NetFirewallRule...
9 Send {Send-EtwTraceSession, Send-PSCONFConfirmation...
9 Find {Find-Command, Find-DscResource, Find-Module, ...
9 ConvertFrom {ConvertFrom-SddlString, ConvertFrom-TypeToScr...
7 Save {Save-Module, Save-NetGPO, Save-NetworkSwitchC...
7 Repair {Repair-FileIntegrity, Repair-VirtualDisk, Rep...
7 Debug {Debug-FileShare, Debug-MMAppPrelaunch, Debug-...
7 Format {Format-Hex, Format-Volume, Format-Custom, For...
6 Suspend {Suspend-BitLocker, Suspend-PrintJob, Suspend-...
6 Install {Install-Dtc, Install-ISEPreviewShortcut, Inst...
6 Publish {Publish-BCFileContent, Publish-BCWebContent, ...
6 Resume {Resume-BitLocker, Resume-PrintJob, Resume-Bit...
6 Move {Move-Control, Move-SmbWitnessClient, Move-App...
5 Restore {Restore-DscConfiguration, Restore-NetworkSwit...
5 Restart {Restart-NetAdapter, Restart-PcsvDevice, Resta...
5 Select {Select-Date, Select-UIType, Select-Object, Se...
5 Mount {Mount-DiskImage, Mount-AppvClientConnectionGr...
4 Uninstall {Uninstall-Dtc, Uninstall-Module, Uninstall-Sc...
4 Disconnect {Disconnect-IscsiTarget, Disconnect-VirtualDis...
4 Connect {Connect-IscsiTarget, Connect-VirtualDisk, Con...
4 Receive {Receive-DtcDiagnosticTransaction, Receive-Job...
4 Unblock {Unblock-FileShareAccess, Unblock-SmbShareAcce...
4 Assert {Assert-MockCalled, Assert-MockCalled, Assert-...
4 Wait {Wait-Debugger, Wait-Event, Wait-Job, Wait-Pro...
3 Complete {Complete-BitsTransfer, Complete-DtcDiagnostic...
3 Resize {Resize-Partition, Resize-StorageTier, Resize-...
3 Optimize {Optimize-StoragePool, Optimize-Volume, Optimi...
3 Initialize {Initialize-Disk, Initialize-EventHandler, Ini...
3 Expand {Expand-Archive, Expand-WindowsCustomDataImage...
3 Dismount {Dismount-DiskImage, Dismount-AppxVolume, Dism...
3 Close {Close-Control, Close-SmbOpenFile, Close-SmbSe...
3 Convert {Convert-Alias, Convert-Path, Convert-String}
2 Use {Use-Transaction, Use-WindowsUnattend}
2 Undo {Undo-DtcDiagnosticTransaction, Undo-Transaction}
2 Trace {Trace-Command, Trace-SteroidsOutput}
2 Split {Split-Path, Split-WindowsImage}
2 Resolve {Resolve-DnsName, Resolve-Path}
2 Measure {Measure-Command, Measure-Object}
2 Join {Join-DtcDiagnosticResourceManager, Join-Path}
2 Exit {Exit-PSHostProcess, Exit-PSSession}
2 Read {Read-PrinterNfcTag, Read-Host}
2 Block {Block-FileShareAccess, Block-SmbShareAccess}
2 Enter {Enter-PSHostProcess, Enter-PSSession}
2 Revoke {Revoke-FileShareAccess, Revoke-SmbShareAccess}
2 Do {Do-Something, Do-SomethingWeird}
2 Sync {Sync-NetIPsecRule, Sync-AppvPublishingServer}
2 Edit {Edit-StringList, Edit-CIPolicyRule}
2 Hide {Hide-UIElement, Hide-VirtualDisk}
2 Grant {Grant-FileShareAccess, Grant-SmbShareAccess}
1 Unlock {Unlock-BitLocker}
1 Unpublish {Unpublish-AppvClientPackage}
1 Unprotect {Unprotect-CmsMessage}
1 Open {Open-NetGPO}
1 Lock {Lock-BitLocker}
1 Tee {Tee-Object}
1 Switch {Switch-Certificate}
1 Sort {Sort-Object}
1 Backup {Backup-BitLockerKeyProtector}
1 Protect {Protect-CmsMessage}
1 Compress {Compress-Archive}
1 Pop {Pop-Location}
1 Merge {Merge-CIPolicy}
1 Encrypt {Encrypt-Text}
1 Limit {Limit-EventLog}
1 Group {Group-Object}
1 ForEach {ForEach-Object}
1 Confirm {Confirm-SecureBootUEFI}
1 Decrypt {Decrypt-Text}
1 Compare {Compare-Object}
1 Checkpoint {Checkpoint-Computer}
1 Push {Push-Location}
1 Where {Where-Object}

更有趣的是,以下是 PowerShell cmdlet 前六个最常用的动词:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
PS C:\> Get-Command -CommandType cmdlet, function  |
Group-Object -Property Verb |
Sort-Object -Property Count -Descending |
Where-Object { $_.Name } |
Select-Object -First 6 -Property Count, Name

Count Name
----- ----
456 Get
210 Set
120 Remove
102 New
72 Enable
67 Add

所以说这头六个动词只占动词总数的 6%,但是占了所有命令的 60% 以上。

PowerShell 技能连载 - 最常用的动词

http://blog.vichamp.com/2016/12/08/most-popular-verbs/

作者

吴波

发布于

2016-12-08

更新于

2022-07-06

许可协议

评论