上个月我有下面的excel表格

当前月份excel表如下

现在,我想查找当前月份添加的新服务器名称,然后列出它们,如下所示

到目前为止,我得到了以下代码。有什么好主意吗?我将用windows调度器任务来调度这个任务,.This应该是powershell,因为我将在以后添加更多的代码,如何从SMB共享中选择正确的excel表。
我在试这个
$oldbk = Import-Excel -Path '\\hcohesity05\cohesity_reports\2022\7\07-29\Cohesity_FETB_Report-2022-07-29-14-26-48.xlsx'
$newbk = Import-Excel -Path '\\hcohesity05\cohesity_reports\2022\8\08-26\Cohesity_FETB_Report-2022-08-26-14-26-48.xlsx'
$Compare = Compare-Object $oldbk $newbk -Property "Server Name" -includeDifferent -PassThru
$Compare | Export-Excel -Path '.\diff.xlsx'但是,无法找到与参数名称“message deDiff传”匹配的参数。
发布于 2022-09-02 00:15:36
通过查看您的代码,我假设您只对查找服务器感兴趣,而不是在旧的Excel文档中显示,如果您只需要Where-Object进行过滤:
$oldbk = Import-Excel -Path 'path\to\oldfile.xlsx'
Import-Excel -Path 'path\to\newfile.xlsx' | Where-Object {
$_."Server Name" -notin $oldbk."Server Name"
} | Export-Excel -Path 'path\to\diff.xlsx'至于错误消息,Compare-Object没有-IncludeDifferent参数,并显示了两个对象之间的差异(默认情况下为)。
$Compare = Compare-Object $oldbk $newbk -Property "Server Name" -PassThruhttps://stackoverflow.com/questions/73574674
复制相似问题