Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Task Scheduler & PowerShell Script

Posted on 2014-10-23
6
Medium Priority
?
409 Views
Last Modified: 2014-10-29
Hello Experts,

I'd like to create a task in the task scheduler to automatically run a powershell script that:

1. map a network drive with credential (\\servername\folderA\subfolderA, username, password)
2. execute the script TOTO.VBS
3. copy the script to my physical c:\ drive, not the VM one (\\Tsclient\c\results)
4. unmap the network drive

Can you help?
0
Comment
Question by:mldaigle1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 71

Expert Comment

by:Qlemo
ID: 40399478
That does not make (much) sense, and even if I would rather stay with a traditional cmd batch file.

"copy the script" - you probably mean the results generated by the script? Which is a file?
"\\Tsclient\c\results" - that requires you to have a terminal client session (RDP) open, or the VM console (probably its Virtual PC?).
0
 

Author Comment

by:mldaigle1
ID: 40399620
oops  your right.... copy the result TXT to my physical workstation and yes i do a RDP to a VMware session
0
 
LVL 71

Accepted Solution

by:
Qlemo earned 1500 total points
ID: 40399711
As .cmd file (PS is oversized here):
@echo off
net use \\servername\folderA  /u:username password
pushd \\servername\folderA\subfolderA
cscript //nologo TOTO.VBS
copy TOTO.TXT \\Tsclient\c\results
popd
net use \\servername\folderA /d

Open in new window

You should be able to provide just the batch file name including path when creating the scheduled task.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 

Author Comment

by:mldaigle1
ID: 40400076
Hello Qloemo,

The CMD works fine but it does not work through the task scheduler, getting error 0x02
0
 
LVL 71

Expert Comment

by:Qlemo
ID: 40400595
Which account did you provide for the task? It needs to be some user account, not local system or the like.
For further troubleshooting allow the task to run as your current interactive user, and add
  pause
as last command in the batch file. You should see then if an error is reported.
0
 

Author Comment

by:mldaigle1
ID: 40411977
thanks for your help
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question