Explorer/ExecuteRulesetJob.ps1

param($command)

try {
# $writer = Get-SRxCustomizationWriter
# $writer.Start($command)

    #Write-Host "---------------------------------"
    #Write-Host "BEGIN - ExecuteRulesetJob 1"
    #Write-Host "---------------------------------"

    #Import-Module "Microsoft.PowerShell.Management" -DisableNameChecking -Verbose:$false -Force
    #Import-Module "Microsoft.PowerShell.Utility" -DisableNameChecking -Verbose:$false -Force
# Write-Host ($command | FL | Out-String)
    #Write-Host "command.ts_SourceID = $($command.ts_SourceID)"
    #Write-Host "--modules--"
    #$m = Get-Module
    #Write-Host ($m | FL | Out-String)

    Initialize-SRxEnv -SourceID $command.ts_SourceID# -LoadModule2 $LoadModule
    #if ($global:SRxEnv.Exists) { Start-SRxShell -RuleSet $command.ts_RuleSet -isJob }
    #$global:SRxEnv.SourceTag = $($command.ts_SourceID)
    $global:SRxEnv.SetCustomProperty("SourceTag", $command.ts_SourceID)
    #Write-Host "SourceTag = $($global:SRxEnv.SourceTag)"


    if ($global:SRxEnv.Exists) {
        Set-SRxCommand -command $command 
        if( $global:SRxEnv.SOP.ts_IsAdmin -and (-not $global:SRxEnv.isStakeHolder)) {
            $output = New-SRxReport -RuleSet "Invoke-NotImplemented"
        }
        else {
            Connect-SRxSPOService #refresh it
            $output = New-SRxReport -RuleSet $global:SRxEnv.SOP.ts_RuleSet
        }  
    }
        
    #Write-Host "---------------------------------"
    #Write-Host "END - ExecuteRulesetJob "
    #Write-Host "---------------------------------"

}
catch {
    Write-Host "ERROR - ExecuteRulesetJob "
    Write-Host ($_.Exception.Message)
}

#$object = [pscustomobject]$command
#$object