Windows – 每个开发人员应该知道的PowerShell脚本
发布时间:2020-12-14 04:32:02 所属栏目:Windows 来源:网络整理
导读:Windows PowerShell现在已经很久了.与老旧的windows shell相比,功能更强大. 您是否有任何脚本来加快和简化您作为开发人员的日常工作?如果你能用PowerShell做魔术 – 请与我们分享! 更新 不是一个脚本,而且非常有用的是PowerShell Community Extensions.该
Windows PowerShell现在已经很久了.与老旧的windows shell相比,功能更强大.
您是否有任何脚本来加快和简化您作为开发人员的日常工作?如果你能用PowerShell做魔术 – >请与我们分享! 更新
我在命令行中放置了一堆脚本与Subversion一起使用.他们大多数只是使用–xml选项来以对象形式放置各种信息.这里有几个例子:
function Get-SvnStatus( [string[]] $Path = ".",[string] $Filter = "^(?!unversioned|normal|external)",[switch] $NoFormat ) { # powershell chokes on "wc-status" and doesn't like two definitions of "item" [xml]$status = ( ( Invoke-Expression "svn status $( $Path -join ',' ) --xml" ) -replace "wc-status","svnstatus" ) ` -replace "item=","itemstatus=" $statusObjects = $status.status.target | Foreach-Object { $_.entry } | Where-Object { $_.svnstatus.itemstatus -match $Filter } | Foreach-Object { $_ | Select-Object @{ Name = "Status"; Expression = { $_.svnstatus.itemstatus } },@{ Name = "Path"; Expression = { Join-Path ( Get-Location ) $_.path } } } | Sort-Object Status,Path if ( $NoFormat ) { $statusObjects } else { $statusObjects | Format-Table -AutoSize } } function Get-SvnLog( [string] $Path = ".",[int] $Revision,[int] $Limit = -1,[switch] $Verbose,[switch] $NoFormat ) { $revisionString = "" $limitString = "" $verboseString = "" if ( $Revision ) { $revisionString = "--revision $Revision" } if ( $Limit -ne -1 ) { $limitString = "--limit $Limit" } if ( $Verbose ) { $verboseString = "--verbose" } [xml]$log = Invoke-Expression "svn log $( $path -join ',' ) --xml $revisionString $limitString $verboseString" $logObjects = $log.log.logentry | Foreach-Object { $logEntry = $_ $logEntry | Select-Object ` @{ Name = "Revision"; Expression = { [int]$logEntry.revision } },@{ Name = "Author"; Expression = { $logEntry.author } },@{ Name = "Date"; Expression = { if ( $NoFormat ) { [datetime]$logEntry.date } else { "{0:dd/MM/yyyy hh:mm:ss}" -f [datetime]$logEntry.date } } },@{ Name = "Message"; Expression = { $logEntry.msg } } | Foreach-Object { # add the changed path information if the $Verbose parameter has been specified if ( $Verbose ) { $_ | Select-Object Revision,Author,Date,Message,@{ Name = "ChangedPaths"; Expression = { $paths = $logEntry.paths.path | Foreach-Object { $_ | Select-Object ` @{ Name = "Change"; Expression = { switch ( $_.action ) { "A" { "added" } "D" { "deleted" } "M" { "modified" } "R" { "replaced" } default { $_.action } } } },@{ Name = "Path"; Expression = { $_."#text" } } } if ( $NoFormat ) { $paths } else { ( $paths | Sort-Object Change | Format-Table -AutoSize | Out-String ).Trim() } } } } else { $_ } } } if ( $NoFormat ) { $logObjects } else { $logObjects | Format-List } } 我有这些别名svns和svnl分别.我谈了几个人here. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 无法使用Selenium和IEWebDriverServer 3.4.0在Windows Serv
- Windows – 如何在x64上为我的进程启用对齐异常?
- windows2003服务器C盘的清理方法
- windows-phone-7 – WP7环绕图像的文字
- windows-server-2008-r2 – Windows Server 2008 R2图元文件
- windows-server-2008 – Windows 2008 DFS复制问题
- Windows中当前目录和工作目录之间的区别
- Windows – 获取包含32位程序的“程序文件”文件夹的路径
- windows-server-2008 – Hyper-V:从子网为VM分配公共IP
- 保护Windows VPS的最佳方法
推荐文章
站长推荐
- windows – Xampp – 安装SQL Server和Visual St
- windows – 如何更改nsis快捷方式的开头?
- 在Windows 10中,我们如何确定窗口所属的虚拟桌面
- 简单探究一下window下的wifi各种东西
- windows-phone-7 – wp7 – 带有大量文本的TextB
- dell-poweredge – 是否可以在带有PERC S100卡的
- windows – 完全禁用Hyper-V VM中的日期和时间同
- 窗口 – 如何确定文件碎片的程度?
- windows-8 – windows 8商店应用程序 – 依赖性问
- windows – 在Visual Studio 2010 Express中创建
热点阅读