- Aug 21, 2002
- 18,368
- 11
- 81
I'm running a powershell script from a remote machine. The script needs to get a list of scheduled tasks so I'm using the following block of code:
Then I do some more work with the tasks. The machine running the script and the remote machine the script is querying for scheduled tasks are domain members and my user account is a Domain Admin and the Domain Admins group is a member of the Local Administrators group on both machines. Everything works fine.
However, I have another domain account which is a service account. It is not a Domain Admin, but it is in the Local Administrators group on both machines. The script will not run with this account - it dies with an access denied message on the second line I posted above:
I tried running the script again and passed in the credentials for a local account in the Local Administrators group on the remote server and it works fine.
If this were a home project, I'd just run the script with an account that works, but this is something I'm doing at work, so I must use the service account we have set up to run a script like the one I'm running. Any ideas what permissions could be missing from the service account that's causing it to get smacked down and doesn't get issued by being a member of the Local Administrators group on all servers involved?
Code:
$Service = New-Object -ComObject Schedule.Service
$Service.connect($Comp)
Then I do some more work with the tasks. The machine running the script and the remote machine the script is querying for scheduled tasks are domain members and my user account is a Domain Admin and the Domain Admins group is a member of the Local Administrators group on both machines. Everything works fine.
However, I have another domain account which is a service account. It is not a Domain Admin, but it is in the Local Administrators group on both machines. The script will not run with this account - it dies with an access denied message on the second line I posted above:
Code:
Exception 1:
Message: Exception calling "Connect" with "1" argument(s): "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"
Source: System.Management.Automation
Exception Source: System.Collections.ListDictionaryInternal
Exception 2:
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
Exception Source: System.Collections.ListDictionaryInternal
Exception 3:
Message: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Exception Source: System.Collections.ListDictionaryInternal
I tried running the script again and passed in the credentials for a local account in the Local Administrators group on the remote server and it works fine.
If this were a home project, I'd just run the script with an account that works, but this is something I'm doing at work, so I must use the service account we have set up to run a script like the one I'm running. Any ideas what permissions could be missing from the service account that's causing it to get smacked down and doesn't get issued by being a member of the Local Administrators group on all servers involved?