Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Can only execute gpg from powershell under MY account

Reply
 
Old 01-23-2009   #1 (permalink)
Blargh


 
 

Can only execute gpg from powershell under MY account

I've built a powershell script that calls gpg and encrypts a file.
Basically, when I run the script in the powershell window, it runs and
encrypts the file. When I run it from Task Scheduler under ANY
ACCOUNT other than my own (even local admin), the encrypt doesn't
work. Unfortunately, gpg doesn't have a logging mechanism so I can't
see what it's actually doing and the Event log doesn't help either.
In the task manager, I don't see gpg.exe popping up in either case,
but maybe the task manager refresh is too slow? I do see "dwm.exe"
come up when run under my account and not an admin.
I checked all permissions using cacls and my account doesn't come up
anywhere on its own, so it doesn't appear to be an issue where just my
user has access to something.

What should I try next?

My System SpecsSystem Spec
Old 01-23-2009   #2 (permalink)
Blargh


 
 

Re: Can only execute gpg from powershell under MY account

On Jan 23, 11:58*am, Blargh <kri...@xxxxxx> wrote:
Quote:

> I've built a powershell script that calls gpg and encrypts a file.
> Basically, when I run the script in the powershell window, it runs and
> encrypts the file. *When I run it from Task Scheduler under ANY
> ACCOUNT other than my own (even local admin), the encrypt doesn't
> work. *Unfortunately, gpg doesn't have a logging mechanism so I can't
> see what it's actually doing and the Event log doesn't help either.
> In the task manager, I don't see gpg.exe popping up in either case,
> but maybe the task manager refresh is too slow? *I do see "dwm.exe"
> come up when run under my account and not an admin.
> I checked all permissions using cacls and my account doesn't come up
> anywhere on its own, so it doesn't appear to be an issue where just my
> user has access to something.
>
> What should I try next?
I should mention I'm running Windows 2008.
My System SpecsSystem Spec
Old 01-23-2009   #3 (permalink)
Vadims Podans


 
 

Re: Can only execute gpg from powershell under MY account

What you actually run in Task Scheduler and how (show us full command line
string)?

--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv

"Blargh" <kripes@xxxxxx> rakstīja ziņojumā
"news:94455d73-0db4-476f-8c34-85e89c134d71@xxxxxx"...
Quote:

> On Jan 23, 11:58 am, Blargh <kri...@xxxxxx> wrote:
Quote:

>> I've built a powershell script that calls gpg and encrypts a file.
>> Basically, when I run the script in the powershell window, it runs and
>> encrypts the file. When I run it from Task Scheduler under ANY
>> ACCOUNT other than my own (even local admin), the encrypt doesn't
>> work. Unfortunately, gpg doesn't have a logging mechanism so I can't
>> see what it's actually doing and the Event log doesn't help either.
>> In the task manager, I don't see gpg.exe popping up in either case,
>> but maybe the task manager refresh is too slow? I do see "dwm.exe"
>> come up when run under my account and not an admin.
>> I checked all permissions using cacls and my account doesn't come up
>> anywhere on its own, so it doesn't appear to be an issue where just my
>> user has access to something.
>>
>> What should I try next?
>
> I should mention I'm running Windows 2008.
My System SpecsSystem Spec
Old 01-23-2009   #4 (permalink)
Blargh


 
 

Re: Can only execute gpg from powershell under MY account

On Jan 23, 1:49*pm, "Vadims Podans" <vpodans> wrote:
Quote:

> What you actually run in Task Scheduler and how (show us full command line
> string)?
>
> --
> WBR, Vadims Podans
> PowerShell blog -www.sysadmins.lv
>
> "Blargh" <kri...@xxxxxx> rakstīja ziņojumā
> "news:94455d73-0db4-476f-8c34-85e89c134d71@xxxxxx"....
>
Quote:

> > On Jan 23, 11:58 am, Blargh <kri...@xxxxxx> wrote:
Quote:

> >> I've built a powershell script that calls gpg and encrypts a file.
> >> Basically, when I run the script in the powershell window, it runs and
> >> encrypts the file. When I run it from Task Scheduler under ANY
> >> ACCOUNT other than my own (even local admin), the encrypt doesn't
> >> work. Unfortunately, gpg doesn't have a logging mechanism so I can't
> >> see what it's actually doing and the Event log doesn't help either.
> >> In the task manager, I don't see gpg.exe popping up in either case,
> >> but maybe the task manager refresh is too slow? I do see "dwm.exe"
> >> come up when run under my account and not an admin.
> >> I checked all permissions using cacls and my account doesn't come up
> >> anywhere on its own, so it doesn't appear to be an issue where just my
> >> user has access to something.
>
Quote:
Quote:

> >> What should I try next?
>
Quote:

> > I should mention I'm running Windows 2008.
>
>
Here is my code (with some maneuvering to anonymise it)



# Input: Required: mydir, which is the directory that the source files
are in. It is also used to determine
# the destination dir. Therefore, both must be identical. ie
"filedir\subdir" (without quotes!)

# Grab passed in variable
$mydir = $args[0]

$sourcedir = "c:\outbound\myproject\my\" + $mydir + "\*.*"
$filearray = get-item $sourcedir
if ($filearray.length -gt 0)
{
# mysys is the ID for the pgp key
$filearray | foreach-object { c:\dev\gpg\gpg.exe --encrypt --
recipient mysys $_ }
# Copy source files to archive folder
copy-item c:\outbound\myproject\my\$mydir\*.* -destination c:\outbound
\myproject\my\archive\$mydir
# Move encrypted files to ftp
move-item -path c:\outbound\myproject\my\$mydir\*.gpg -destination \
\serverftp\ftp$\1234\$mydir
# Remove all leftover files (for a clean run next time)
remove-item -path c:\outbound\myproject\my\$mydir\*.* -force

}
else
{"There are no files to process"}
My System SpecsSystem Spec
Old 01-23-2009   #5 (permalink)
Blargh


 
 

Re: Can only execute gpg from powershell under MY account

On Jan 23, 1:49*pm, "Vadims Podans" <vpodans> wrote:
Quote:

> What you actually run in Task Scheduler and how (show us full command line
> string)?
>
> --
> WBR, Vadims Podans
> PowerShell blog -www.sysadmins.lv
>
> "Blargh" <kri...@xxxxxx> rakstīja ziņojumā
> "news:94455d73-0db4-476f-8c34-85e89c134d71@xxxxxx"....
>
Quote:

> > On Jan 23, 11:58 am, Blargh <kri...@xxxxxx> wrote:
Quote:

> >> I've built a powershell script that calls gpg and encrypts a file.
> >> Basically, when I run the script in the powershell window, it runs and
> >> encrypts the file. When I run it from Task Scheduler under ANY
> >> ACCOUNT other than my own (even local admin), the encrypt doesn't
> >> work. Unfortunately, gpg doesn't have a logging mechanism so I can't
> >> see what it's actually doing and the Event log doesn't help either.
> >> In the task manager, I don't see gpg.exe popping up in either case,
> >> but maybe the task manager refresh is too slow? I do see "dwm.exe"
> >> come up when run under my account and not an admin.
> >> I checked all permissions using cacls and my account doesn't come up
> >> anywhere on its own, so it doesn't appear to be an issue where just my
> >> user has access to something.
>
Quote:
Quote:

> >> What should I try next?
>
Quote:

> > I should mention I'm running Windows 2008.
>
>
Oh, and Task Scheduler runs "powershell" (no quotes) with an argument
of "c:\scripts\myscript.ps1" (with quotes)
My System SpecsSystem Spec
Old 01-23-2009   #6 (permalink)
Vadims Podans


 
 

Re: Can only execute gpg from powershell under MY account

I see $args[0] variable in script (where you pass a path to script). However
in call line you don't pass any data to script. Here should be something
like this:
C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
"c:\scripts\myscript.ps1 data"

where Data - your data that will passed as $args[0].

--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv

"Blargh" <kripes@xxxxxx> rakstīja ziņojumā
"news:0baaed59-69f9-4e1a-b66e-e44ea0ce57db@xxxxxx"...
Quote:

> On Jan 23, 1:49 pm, "Vadims Podans" <vpodans> wrote:
Quote:

>> What you actually run in Task Scheduler and how (show us full command
>> line
>> string)?
>>
>> --
>> WBR, Vadims Podans
>> PowerShell blog -www.sysadmins.lv
>>
>> "Blargh" <kri...@xxxxxx> rakstīja ziņojumā
>> "news:94455d73-0db4-476f-8c34-85e89c134d71@xxxxxx"...
>>
Quote:

>> > On Jan 23, 11:58 am, Blargh <kri...@xxxxxx> wrote:
>> >> I've built a powershell script that calls gpg and encrypts a file.
>> >> Basically, when I run the script in the powershell window, it runs and
>> >> encrypts the file. When I run it from Task Scheduler under ANY
>> >> ACCOUNT other than my own (even local admin), the encrypt doesn't
>> >> work. Unfortunately, gpg doesn't have a logging mechanism so I can't
>> >> see what it's actually doing and the Event log doesn't help either.
>> >> In the task manager, I don't see gpg.exe popping up in either case,
>> >> but maybe the task manager refresh is too slow? I do see "dwm.exe"
>> >> come up when run under my account and not an admin.
>> >> I checked all permissions using cacls and my account doesn't come up
>> >> anywhere on its own, so it doesn't appear to be an issue where just my
>> >> user has access to something.
>>
Quote:

>> >> What should I try next?
>>
Quote:

>> > I should mention I'm running Windows 2008.
>>
>>
>
> Oh, and Task Scheduler runs "powershell" (no quotes) with an argument
> of "c:\scripts\myscript.ps1" (with quotes)
My System SpecsSystem Spec
Old 01-27-2009   #7 (permalink)
Blargh


 
 

Re: Can only execute gpg from powershell under MY account

On Jan 23, 5:15 pm, "Vadims Podans" <vpodans> wrote:
Quote:

> I see $args[0] variable in script (where you pass a path to script). However
> in call line you don't pass any data to script. Here should be something
> like this:
> C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
> "c:\scripts\myscript.ps1 data"
>
> where Data - your data that will passed as $args[0].
>
> --
> WBR, Vadims Podans
> PowerShell blog -www.sysadmins.lv
>
> "Blargh" <kri...@xxxxxx> rakstīja ziņojumā
> "news:0baaed59-69f9-4e1a-b66e-e44ea0ce57db@xxxxxx"....
>
Quote:

> > On Jan 23, 1:49 pm, "Vadims Podans" <vpodans> wrote:
Quote:

> >> What you actually run in Task Scheduler and how (show us full command
> >> line
> >> string)?
>
Quote:
Quote:

> >> --
> >> WBR, Vadims Podans
> >> PowerShell blog -www.sysadmins.lv
>
Quote:
Quote:

> >> "Blargh" <kri...@xxxxxx> rakstīja ziņojumā
> >> "news:94455d73-0db4-476f-8c34-85e89c134d71@xxxxxx"...
>
Quote:
Quote:

> >> > On Jan 23, 11:58 am,Blargh<kri...@xxxxxx> wrote:
> >> >> I've built a powershell script that calls gpg and encrypts a file.
> >> >> Basically, when I run the script in the powershell window, it runs and
> >> >> encrypts the file. When I run it from Task Scheduler under ANY
> >> >> ACCOUNT other than my own (even local admin), the encrypt doesn't
> >> >> work. Unfortunately, gpg doesn't have a logging mechanism so I can't
> >> >> see what it's actually doing and the Event log doesn't help either.
> >> >> In the task manager, I don't see gpg.exe popping up in either case,
> >> >> but maybe the task manager refresh is too slow? I do see "dwm.exe"
> >> >> come up when run under my account and not an admin.
> >> >> I checked all permissions using cacls and my account doesn't come up
> >> >> anywhere on its own, so it doesn't appear to be an issue where justmy
> >> >> user has access to something.
>
Quote:
Quote:

> >> >> What should I try next?
>
Quote:
Quote:

> >> > I should mention I'm running Windows 2008.
>
Quote:

> > Oh, and Task Scheduler runs "powershell" (no quotes) with an argument
> > of "c:\scripts\myscript.ps1" (with quotes)
I messed up. It's calling it with the argument: "c:\scripts
\myscript.ps1 parentdir\childdir"

I figured out the problem. gpg imports keys for use only on a per-
user basis. So I had to log on as the other user and re-import they
key.

In addition, some directories on the server were not accessible for
file deletion by my script under ANY account (even though they had
access in the security tab). So I changed the task to run under the
highest privileges.

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
How to execute external program from powershell PowerShell
Execute a powershell script from a webpage PowerShell
How to execute a webtest from Powershell PowerShell
Powershell Execute process PowerShell
How to execute (perl) scripts in Powershell without DOS box PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46