lithnet / miis-powershell

Lithnet PowerShell Module for FIM/MIM Synchronization Service
Microsoft Public License
40 stars 9 forks source link

Get-MVObject fails when running the script in a schedule task #28

Closed majdandoni closed 4 years ago

majdandoni commented 4 years ago

Hi,

I have the following script:

Import-Module LithnetMIISAutomation sleep -Seconds 2

Get the metaverse object

$queryfilter = @(); $queryfilter += New-MVQuery -Attribute legalHold -Operator IsPresent $results = Get-MVObject -Queries $queryfilter

When i run it using Powershell ISE, it runs successfully. However, when i run it in a scheduled task under the same user that ran it in Powershell ISE, i get the following error "The Synchronization Service Manager service has stopped." While the Sync service is actually running and never was stopped.

worth to mention that i'm using windows task scheduler to schedule the task running the script.

any ideas?

ryannewington commented 4 years ago

@majdandoni

This is a known issue that the MIM Sync APIs do not support impersonation. This is what task scheduler users to run the script. Check out the issue below for more information and a few things you might be able to try to get it working.

https://github.com/lithnet/miis-powershell/issues/24

Unfortunately, it's not something I can resolve in the PowerShell module itself.