Unable to run Get-GAGroupMember in scheduled task

21 views
Skip to first unread message

cho...@georgiasouthern.edu

unread,
May 11, 2017, 3:36:44 PM5/11/17
to gshell-discuss
Hey everyone,

I've written a script that will populate a Google group. The first thing I do is run Get-GAGroupMember to get all the current members then I see who I need to add. The script works fine when I run it manually, when I run the scheduled task on demand and when I schedule the task to run while still being logged in but if I schedule the task then I log out that command won't work. I'm running with highest credentials and I'm running whether user is logged in or not.

Any ideas about what's going on? Thanks!

cho...@georgiasouthern.edu

unread,
May 12, 2017, 9:44:25 AM5/12/17
to gshell-discuss, cho...@georgiasouthern.edu

Just an update it seems it can't find the module unless the user that the task is scheduled under, is logged in. Any ideas? I'm importing gShell and I even tried the direct path (C:\Users\User\Docs....). Thanks.

cho...@georgiasouthern.edu

unread,
May 12, 2017, 10:25:17 AM5/12/17
to gshell-discuss, cho...@georgiasouthern.edu

Another update it seems when the user is not logged in it uses either the system account or default user. The error it gives me is:

The member 'FormatsToProcess' in the module manifest is not valid: Cannot find path 'C:\Users\Default\Documents\WindowsPowerShell\Modules\gShell\gShell.Format.ps1xml' because it does not exist.. Please make sure that a valid value is specified for this field in file 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules\gShell\gShell.psd1'.

I can copy the gShell folder there but then I get other issues. Is there a way to set this up so it can run in a scheduled task?

Spencer Varney

unread,
May 12, 2017, 4:38:38 PM5/12/17
to cho...@georgiasouthern.edu, gshell-discuss
Hey man sorry for the delay. The only thing I could think of, like you mentioned, is that when you're running the task it doesn't have access to all of the things your user account does (like system variables). I'm not a pro on that specifically, but my thoughts to first try would be this:

1) Make gshell available to all users by putting it in C:\Windows\System32\WindowsPowerShell\v1.0\Modules. Powershell checks there for modules installed for all users, so maybe that would work.

2) At the top of your script, add a direct import-module to the path of your install for the local user, eg:
Import-Module C:\Users\chorton\Documents\WindowsPowerShell\Modules\gShell\gShell.dll

Do either of those work?

Regards,

Spencer

--
You received this message because you are subscribed to the Google Groups "gshell-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gshell-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages