rawales2
asked on
powershell script task in task manager won't stop
I have a powershell script that I am trying to run from task scheduler. The script looks in the ou "domain user accounts" for the extensionAttribute1 value and then exports the list to a csv. The script works fine when executed from powershell but when running it from task scheduler it never finishes running. The exported csv is created however.
Here is the script-
The task is running as domain\administrator with highest privileges.
It is set to run powershell with the arguments-
-ExecutionPolicy Bypass c:\scripts\exportOWA.ps1
Thanks in advance.
Here is the script-
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$OU='OU=domain user accounts,DC=domain,DC=local'
$ext14='mf7_6'
Get-Mailbox -OrganizationalUnit $OU|
Where {($_.customAttribute1 -eq $ext14)} | export-csv c:\userstest.txt
The task is running as domain\administrator with highest privileges.
It is set to run powershell with the arguments-
-ExecutionPolicy Bypass c:\scripts\exportOWA.ps1
Thanks in advance.
Make sure you manually refresh the Task Scheduler display. It does often not reflect the actual state of tasks.
ASKER
Thanks, but I have been manually refreshing.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ok. when I add the no exit argument it just brings up powershell with a prompt... I've also tried -NoExit -command ". 'C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExcha nge.ps1'; Connect-ExchangeServer -auto; c:\Scripts\exportOWAps1"
This loads the exchange tools and connects to my exchange server but then just sits..
This loads the exchange tools and connects to my exchange server but then just sits..
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
The script is not expected to provide any feedback, so an empty box is ok.
Did you run as your user or as admin?
Did you run as your user or as admin?
ASKER
yes. it's all good.
ASKER
Given credit to you for the -NoExit - that was really helpful.