我在do-until块中使用以下内容循环,直到存在指定的Exchange Online迁移状态:
(Get-Migrationbatch -Identity $MigrationBatchName | Where {$_.Status -like "Completed" -or "CompletedWithErrors" -or "Corrupted" -or "Failed" -or "Stopped"})
Run Code Online (Sandbox Code Playgroud)
但是,上面仍然返回状态为"正在同步"的作业,因此无论如何都会继续执行该脚本.
我试过-match,-eq但仍然是一样的.
我错过了什么?
此问题最流行的答案涉及以下 Windows powershell 代码(已编辑以修复错误):
$file1 = Get-Content C:\temp\file1.txt
$file2 = Get-Content C:\temp\file2.txt
$Diff = Compare-Object $File1 $File2
$LeftSide = ($Diff | Where-Object {$_.SideIndicator -eq '<='}).InputObject
$LeftSide | Set-Content C:\temp\file3.txt
Run Code Online (Sandbox Code Playgroud)
我总是得到一个零字节文件作为输出,即使我删除了 $Diff 行。
为什么输出文件总是为空,如何修复?