手机
当前位置:查字典教程网 >脚本专栏 >PowerShell >Powershell比较两个文件夹的不同
Powershell比较两个文件夹的不同
摘要:快速找出两个文件夹中不同的部分,可以使用下面例子:复制代码代码如下:$list1=Get-ChildItemc:Windowssystem3...

快速找出两个文件夹中不同的部分,可以使用下面例子:

复制代码 代码如下:

$list1 = Get-ChildItem c:Windowssystem32 | Sort-Object -Property Name

$list2 = Get-ChildItem server12c$windowssystem32 | Sort-Object -Property Name

Compare-Object -ReferenceObject $list1 -DifferenceObject $list2 -Property Name |

Sort-Object -Property Name

首先,脚本得到两个不同列表变量,一个来自本地,一个来自远程电脑,接着Compare-Object将从中分析出两边的不同处。

【Powershell比较两个文件夹的不同】相关文章:

Powershell中定义常量的方法

PowerShell中对函数参数的命名建议

PowerShell包含另一个脚本文件和获取当前脚本所在目录的方法例子

Powershell获取系统中所有可停止的服务

Powershell打印文本文档例子

PowerShell中按文件后缀过滤的实现代码

Windows Powershell 执行文件和脚本

PowerShell ISE中代码转换大小写的技巧

PowerShell中的变量基础知识介绍

Powershell小技巧之保存服务信息

精品推荐
分类导航