PowerShell: cmdlet

  

Service:

  1. get-service

      

  2. start-service
    start-service -name spooler -v 

     

  3. stop-service

  4. restart-service
    get-service -name spooler | restart-service

     

  5. get-service      

      

  6. get-service | findstr httpd                    Case-Sensitive

  7. 获取停止的服务
    get-service | where {$_.status -match 'stopped'}

      

Process

  1. ps === get-process

  2.   

文本处理

  1. get-content === cat

  2. select-string String file

Select-String:

  Select-String -Path D:/b.log -Pattern '\d{2,}'
  Get-ChildItem -recurse -filter *.log c:/ | Select-String "\w+" | Copy-Item -Destination C:\temp2

 

$profile: 

  

"`nnew-alias which get-command" | add-content $profile

 

 

posted @ 2021-04-29 09:09  ascertain  阅读(83)  评论(0编辑  收藏  举报