header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Works manually but not as a scheduled task
Last Post 30 May 2008 08:54 PM by slowpoh. 7 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
slowpohUser is Offline
New Member
New Member
Posts:4

--
23 May 2008 10:06 PM  

I'm having problems running a script through the schedule task.  It runs fine when I run it manually through PS or if I start the Task manually from the Task Scheduler window.  However, if I logoff the machine, the script runs but it doesn't seem to evaluate a "if" logic conditional properly. 

Specifically i'm evaluating the following:

If (test-path \\uncname\folder\*zip)
{

}
else
{
 
}

When I run it unattended through the Scheduled Tasks, it always evaluates false and executes whatever is in the else field. 

I've checked the Task Scheduler account that is running the script.  I'm using the same account either running it manually or unattended.

Any ideas on how to troubleshoot?

DonJUser is Offline
PowerShell MVP
Basic Member
Basic Member
Posts:134

--
23 May 2008 10:23 PM  
When you run the script manually, is Windows prompting you for a password or anything via a pop-up (I'm guessing not)? This is almost surely some kind of security-related issue - tough to troubleshoot, for sure. It may be something requiring the presence of an interactive session (e.g., your interactive logon).

Out of curiosity, can you write a test script that just tries to read or write a text file from your UNC path, rather than testing for its existence?
slowpohUser is Offline
New Member
New Member
Posts:4

--
27 May 2008 03:20 PM  

I was unable to perform a copy-item cmdlet with that UNC via unattended schedule task.  Also, i found out that  the UNC I'm trying to get at is a FTP server that is not part of our domain.  (Just to check, I was able to verify that I can check for this existence of a file, and copy it from computers that are a part of our domain through an unattended schedule task job.)  The FTP server is a Windows 2003 box, I can map a drive to it, etc...  And the script still works when I run it directly, just not when it's an unattended scheduled task.

So it still looks like the other variable is figuring what's going on with computers not part of the domain.  Some kind of security issue at play that I'm not aware of yet...

 

halr9000User is Offline
Basic Member
Basic Member
Posts:303

--
27 May 2008 07:08 PM  
Bet you $10 that you could FTP without problems in the scheduled task. I'm with Don, it is some kind of security issue. I want to say I've seen something like this on the powershell newsgroup a while back, but after some searching I can't find it. Well, while I don't know the "right" way to resolve this, I know a dirty hack which should. If you authenticate using net use I believe the test-path (or any other manipulation over the UNC path) should work after that.

NET USE \\TARGETSERVER\IPC$ /USER:domainname\username password
slowpohUser is Offline
New Member
New Member
Posts:4

--
28 May 2008 04:22 PM  

I wasn't able to figure it out.  However, i did use the net use hack to get by.  Thanks for the help and suggestions.

ShayUser is Offline
Basic Member
Basic Member
Posts:214

--
28 May 2008 05:01 PM  
What's the OS version of the server that runs the scheduled task? I ran into similar problem when the OS was Windows 2000.

ShayUser is Offline
Basic Member
Basic Member
Posts:214

--
28 May 2008 05:05 PM  
Oh.. one more thing, what happens when you schedule a batch file with :

copy c:\testFile.txt \\server\share

and run it when nobody is loggen on to the server?
slowpohUser is Offline
New Member
New Member
Posts:4

--
30 May 2008 08:54 PM  

Shay,
The server is Windows 2003.  The copy test will not work either.  I'd probably have to map a drive, pass authentication and then I can probably copy.

You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer