使用 SailPoint IQService 从服务帐户开始工作
Poweshell Start-Job from serviceAccount using SailPoint IQService
所以这个问题有几个因素在起作用,所以这里是:
- SailPoint 8.2 和 IQService 8.2
- Windows 服务器 2016
- 服务帐户(域管理员)
- 交互式用户帐户(域管理员)
- Powershell 5.1 内部版本 14393 修订版 4583
所以我们得到的是 SailPoint 在其端执行规则,将一些信息发送到 IQService,IQService 正在作为服务帐户执行 PowerShell 脚本。在其中一个 PowerShell 脚本中,我们有以下命令:
LogToFile("calling start job")
$j = Start-Job -ScriptBlock { C:/SailPoint/Scripts/PowershellContainerAfterCreateRetry.ps1 -sAMAccountName $args[0] -company $args[1] } -ArgumentList $sAMAccountName, $company -Name 'PowershellContainerAfterCreateRetry'
LogToFile($j | Select-Object -Property *)
LogToFile("finished start-job")
这就是事情变得有趣的地方,因为这个命令,正如您所注意到的,我们可以记录到文件以查看其输出是什么,如下所示:
calling start job
@{
State=Running; HasMoreData=True;
StatusMessage=;
Location=localhost;
Command= C:/SailPoint/Scripts/PowershellContainerAfterCreateRetry.ps1 -sAMAccountName $args[0] -company $args[1] ;
JobStateInfo=Running;
Finished=System.Threading.ManualResetEvent;
InstanceId=aa889c06-7a8a-402e-807a-880d02465bdd; Id=1;
Name=PowershellContainerAfterCreateRetry;
ChildJobs=System.Collections.Generic.List`1[System.Management.Automation.Job];
PSBeginTime=10/15/2021 21:14:22; PSEndTime=;
PSJobTypeName=BackgroundJob;
Output=System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject];
Error=System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord];
Progress=System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord];
Verbose=System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord];
Debug=System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord];
Warning=System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord];
Information=System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord]}
finished start-job
当我单独或在此脚本中使用 Windows PowerShell ISE 执行此命令时,它完成时没有任何问题并调用有问题的脚本,并且一切正常! (无论我使用的是互动帐户还是服务帐户)
当使用 IQService 执行此脚本时,发生了“其他”事情 - 我说“其他”事情是因为我没有任何日志文件或错误;它似乎消失在以太中。 (我有一个日志在 PowerShell 脚本中写了五行,所以有人会认为我至少会得到一些东西!?!?我没有想法......想法?
作为一个小提示,我 运行 一个实验向我展示了关于设置的一些东西 st运行ge 应该已经成功而没有问题 - 就像上面它似乎执行(因为我可以看到上面相同的信息,这表明作业已经开始)。尽管如此,就像上面一样,它实际上从未“出现”完成或出错。我唯一能想到的是,主脚本以某种方式关闭导致它也关闭 - 但我认为如果是这种情况,它能够写入几个日志文件吗?无论如何......感谢阅读!
$doit = {
"test" | Out-File -filepath ("c:\test.txt") -append
}
Start-job -ScriptBlock $doit
我认为 Start-Job 是这里的问题,因为 iqservice 将启动一个 powershell 脚本进程,它可能不支持您尝试使用的后台作业方面。
如果您需要重试或等待并循环,您将需要使用另一种 identityiq/iqservice 机制(iiq 中的工作流可能会在条件满足、定时器被命中等时调用 AD .) 在 iqservice powershell 脚本中超越开始作业。
所以这个问题有几个因素在起作用,所以这里是:
- SailPoint 8.2 和 IQService 8.2
- Windows 服务器 2016
- 服务帐户(域管理员)
- 交互式用户帐户(域管理员)
- Powershell 5.1 内部版本 14393 修订版 4583
所以我们得到的是 SailPoint 在其端执行规则,将一些信息发送到 IQService,IQService 正在作为服务帐户执行 PowerShell 脚本。在其中一个 PowerShell 脚本中,我们有以下命令:
LogToFile("calling start job")
$j = Start-Job -ScriptBlock { C:/SailPoint/Scripts/PowershellContainerAfterCreateRetry.ps1 -sAMAccountName $args[0] -company $args[1] } -ArgumentList $sAMAccountName, $company -Name 'PowershellContainerAfterCreateRetry'
LogToFile($j | Select-Object -Property *)
LogToFile("finished start-job")
这就是事情变得有趣的地方,因为这个命令,正如您所注意到的,我们可以记录到文件以查看其输出是什么,如下所示:
calling start job
@{
State=Running; HasMoreData=True;
StatusMessage=;
Location=localhost;
Command= C:/SailPoint/Scripts/PowershellContainerAfterCreateRetry.ps1 -sAMAccountName $args[0] -company $args[1] ;
JobStateInfo=Running;
Finished=System.Threading.ManualResetEvent;
InstanceId=aa889c06-7a8a-402e-807a-880d02465bdd; Id=1;
Name=PowershellContainerAfterCreateRetry;
ChildJobs=System.Collections.Generic.List`1[System.Management.Automation.Job];
PSBeginTime=10/15/2021 21:14:22; PSEndTime=;
PSJobTypeName=BackgroundJob;
Output=System.Management.Automation.PSDataCollection`1[System.Management.Automation.PSObject];
Error=System.Management.Automation.PSDataCollection`1[System.Management.Automation.ErrorRecord];
Progress=System.Management.Automation.PSDataCollection`1[System.Management.Automation.ProgressRecord];
Verbose=System.Management.Automation.PSDataCollection`1[System.Management.Automation.VerboseRecord];
Debug=System.Management.Automation.PSDataCollection`1[System.Management.Automation.DebugRecord];
Warning=System.Management.Automation.PSDataCollection`1[System.Management.Automation.WarningRecord];
Information=System.Management.Automation.PSDataCollection`1[System.Management.Automation.InformationRecord]}
finished start-job
当我单独或在此脚本中使用 Windows PowerShell ISE 执行此命令时,它完成时没有任何问题并调用有问题的脚本,并且一切正常! (无论我使用的是互动帐户还是服务帐户)
当使用 IQService 执行此脚本时,发生了“其他”事情 - 我说“其他”事情是因为我没有任何日志文件或错误;它似乎消失在以太中。 (我有一个日志在 PowerShell 脚本中写了五行,所以有人会认为我至少会得到一些东西!?!?我没有想法......想法?
作为一个小提示,我 运行 一个实验向我展示了关于设置的一些东西 st运行ge 应该已经成功而没有问题 - 就像上面它似乎执行(因为我可以看到上面相同的信息,这表明作业已经开始)。尽管如此,就像上面一样,它实际上从未“出现”完成或出错。我唯一能想到的是,主脚本以某种方式关闭导致它也关闭 - 但我认为如果是这种情况,它能够写入几个日志文件吗?无论如何......感谢阅读!
$doit = {
"test" | Out-File -filepath ("c:\test.txt") -append
}
Start-job -ScriptBlock $doit
我认为 Start-Job 是这里的问题,因为 iqservice 将启动一个 powershell 脚本进程,它可能不支持您尝试使用的后台作业方面。
如果您需要重试或等待并循环,您将需要使用另一种 identityiq/iqservice 机制(iiq 中的工作流可能会在条件满足、定时器被命中等时调用 AD .) 在 iqservice powershell 脚本中超越开始作业。