• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell
您的位置:首页 > 脚本语言 >PowerShell > Powershell小技巧之查找脚本中的函数

Powershell小技巧之查找脚本中的函数

作者:hebedich 字体:[增加 减小] 来源:互联网

hebedich 通过本文主要向大家介绍了powershell脚本,powershell执行脚本,powershell 运行脚本,powershell常用脚本,powershell脚本下载等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

要快速获取你PS脚本库中所有文件的函数名,你可以这样做:

filter Find-Function
{
   $path = $_.FullName
   $lastwrite = $_.LastWriteTime
   $text = Get-Content -Path $path
   
   if ($text.Length -gt 0)
   {
      
      $token = $null
      $errors = $null
      $ast = [System.Management.Automation.Language.Parser]::ParseInput($text, [ref] $token, [ref] $errors)
      $ast.FindAll({ $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $true) |
      Select-Object -Property Name, Path, LastWriteTime |
      ForEach-Object {
         $_.Path = $path
         $_.LastWriteTime = $lastwrite
         $_
      }
   }
}
</div>

这将扫描出你用户配置文件夹下的所有PS脚本中的函数:

PS> dir $home -Filter *.ps1 -Recurse -Exclude *.ps1xml | Find-Function
Name                       Path                       LastWriteTime          
----                       ----                       -------------          
Inject-LogonCredentials    C:\Users\Tobias\Desktop... 06.01.2014 02:43:00    
Test-Command               C:\Users\Tobias\Desktop... 06.03.2014 10:17:02    
Test                       C:\Users\Tobias\Desktop... 30.01.2014 09:32:20    
Get-WebPictureOriginal     C:\Users\Tobias\Desktop... 11.12.2013 11:37:53    
Get-ConnectionString       C:\Users\Tobias\Documen... 23.05.2014 10:49:09    
Convert-SID2User           C:\Users\Tobias\Documen... 23.05.2014 15:33:06    
Lock-Screen                C:\Users\Tobias\Documen... 19.03.2014 12:51:54    
Show-OpenFileDialog        C:\Users\Tobias\Documen... 16.05.2014 13:42:16    
Show-UniversalData         C:\Users\Tobias\Documen... 16.05.2014 13:23:20    
Start-TimebombMemory       C:\Users\Tobias\Documen... 23.05.2014 09:12:28    
Stop-TimebombMemory        C:\Users\Tobias\Documen... 23.05.2014 09:12:28    
(...)
</div>

将结果用管道传给Out-GridView 将能得到更完美的信息。

支持PS3.0及以后

</div>

您可能想查找下面的文章:

  • PowerShell因为在此系统中禁止执行脚本的解决方法
  • PowerShell时间记录脚本
  • Powershell实现编写和运行脚本
  • PowerShell脚本反引号用法实例:随时随地给代码换行
  • Powershell脚本的4种执行权限介绍
  • PowerShell中获取当前运行脚本路径的方法
  • PowerShell实现动态获取当前脚本运行时消耗的内存
  • PowerShell实现的文件同步脚本分享
  • Powershell实现获取电脑序列号功能脚本分享
  • Powershell脚本中使用条件断点实例

相关文章

  • PowerShell 读取性能计数器二进制文件(.blg)记录并汇总计算
  • Windows Powershell 快捷键介绍
  • PowerShell脚本中控制Windows DNS服务的方法
  • PowerShell中使用GetType获取变量数据类型
  • Powershell获取系统中所有可停止的服务
  • PowerShell读取文件内容、替换文件内容、读取限定行的例子
  • PowerShell添加本地账户脚本分享
  • Powershell小技巧之用变量累积记录错误
  • PowerShell Out-File向只读文件写入内容的方法
  • 探索PowerShell (三) PowerShell下使用Aliases

文章分类

  • vbs
  • DOS/BAT
  • hta/htc
  • python
  • perl
  • VBA
  • ColdFusion
  • ruby
  • PowerShell
  • Lua
  • Golang
  • linux shell

最近更新的内容

    • PowerShell小技巧之读取Windows产品密钥
    • PowerShell函数中接收管道参数实例
    • PowerShell中Get-Date对象的常用属性和方法介绍
    • 探索PowerShell(十四) 使用WMI对象的方法
    • Windows Powershell 定义变量
    • Powershell小技巧之捕获脚本内部的异常
    • Windows Powershell 进行数学运算
    • PowerShell判断某天是星期几的方法
    • PowerShell实现的文件同步脚本分享
    • PowerShell小技巧之实现文件下载(类wget)

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有