タスク スケジューラのサービス アカウント権限 READ

タスク スケジューラのサービス アカウント権限 READ

アプリケーション サーバー クラスターの 2 つのノード間でスケジュールされたタスクを比較するために作成した PowerShell スクリプトがあります。このコードを使用して、特定のサーバーからタスクを照会します...

function getTasks($server) {
    return Get-ScheduledTask -CimSession $server | 
        Where-Object TaskPath -like '*OurFolder*' | 
        ForEach-Object {
            [pscustomobject]@{ 
                Server = $server
                Path = $_.TaskPath
                Name = $_.TaskName
                Disabled = ($_.State -eq 'Disabled')
                Command = $_.Actions.Execute
                Arguments = $_.Actions.Arguments
                Interval = $_.Triggers.RepetitionInterval
                HashId = "$($_.Actions.Execute)|$($_.Actions.Arguments)"
                HashFull = "$($_.TaskPath)|$($_.TaskName)|$($_.Actions.Execute)|$($_.Actions.Arguments)|$(($_.State -eq 'Disabled'))"
            }
        }
}

ドメイン管理者アカウントで実行すると完璧に動作します。

ただし、スケジュールされたタスクとしてサービス アカウントで実行しようとすると、他のノードでスケジュールされたタスクを照会しようとすると、このエラーが発生します...

Get-ScheduledTask : SERVER.domain.local: Cannot connect to CIM server. Access is denied.
At F:\Applications\TaskSchedulerNodeCompare\compare-nodes.ps1:9 char:12
+     return Get-ScheduledTask -CimSession $server |
+            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (MSFT_ScheduledTask:String) [Get-ScheduledTask], CimJobException
    + FullyQualifiedErrorId : CimJob_BrokenCimSession,Get-ScheduledTask

グーグルで調べてルックスアカウントがこのリストにアクセスできるようにする唯一の方法は、問題のサーバー上の LocalAdmins にアカウントを追加することでしょうか? しかし、サービス アカウントをローカル管理者として作成する必要があるのは本当に正しいとは思えませんし、当然、タスクをドメイン管理者アカウントで実行したくはありません。

私はもう試した解決策3はこちら、 どれのまるでそうなるかのように...

1.  As an Administrator of the server, go to Server Manager -> Tools -> Computer Management.  On the left expand "Services and Applications" and right click "WMI Control".  Go to "Properties".
2.  In the newly open Window, click on Security tab.
3.  Expand Root tree, and then click on the node CIMV2, and click the button security
4.  In the newly open Window, click the button Advanced.
5.  In the newly open Window, click the button Add under the permission tab.
6.  In the newly open Window, click on “select a principal", then search for the user you that was having the problem.  
7.  In the applies to, choose “this namespace and subnamespace".
8.  For the permission, check on “Execute Methods", “Enable Accounts" and “Remote Enable"
9.  Click accept on all the open dialogue boxes
10. Restart WMI services.  As an Admininstrator of the server, go to Server Manager -> Tools -> Computer Management.  On the left expand "Services and Applications" and click on "Services".  Go to "Windows Management Instrumentation" and right click it.  Then choose "Restart".
11. Try the command again. The above directions were adapted from this StackOverflow posting.

しかし、これらすべての手順を実行した後でも、まだ機能しません。

セキュリティを最大限に考慮しながら、サービス アカウントがサーバーからスケジュールされたタスクを (読み取り専用で) 照会できるようにするにはどうすればよいでしょうか?

答え1

私の知る限り、スケジュールされたタスクは作成者またはローカル管理者グループのメンバーのみが表示できます。また、ローカル オブジェクトの権限を変更した後に作成されたタスクなどをカバーする実用的なソリューションがあるかどうかも疑問です。

また、非常に似ていると思われるこの質問/回答も参照してください。 スケジュールされたタスクの権限または ACL

関連情報