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 - schedule a task with WMI?

Reply
 
Old 11-23-2007   #1 (permalink)
Justin Rich


 
 

schedule a task with WMI?

i just wrote a script to do backups (with an imaging product) and now i want
to make a script to deploy this and there are two things i need to do that
im not really sure how to do.

1) create a schedule task with WMI (i want wmi so i can do it remotely)
2) create an account and add it to the admin group
3) modify the remote systems path enviornment var. (not a must, but would be
nice)




My System SpecsSystem Spec
Old 11-24-2007   #2 (permalink)
Desmond Lee


 
 

RE: schedule a task with WMI?

Justin,

One simple way is to use Control Panel > Scheduled Task to call a batch file
(*.bat or *.cmd) that will launch the actual *.ps1 script. Make sure that the
account has the right credentials to connect and function remotely on the
target machine.

Hope this helps. Do let us know. Thanks!

--
http://www.leedesmond.com/weblog/



"Justin Rich" wrote:
Quote:

> i just wrote a script to do backups (with an imaging product) and now i want
> to make a script to deploy this and there are two things i need to do that
> im not really sure how to do.
>
> 1) create a schedule task with WMI (i want wmi so i can do it remotely)
> 2) create an account and add it to the admin group
> 3) modify the remote systems path enviornment var. (not a must, but would be
> nice)
>
>
>
>
My System SpecsSystem Spec
Old 11-26-2007   #3 (permalink)
Chris


 
 

Re: schedule a task with WMI?

To create the tasks remotely use the following WMI class:

Win32_ScheduledJob

It has a method create, by using this method you can create a
schedule.

Details:

http://msdn2.microsoft.com/en-us/library/Aa394399.aspx


regards

On 24 Nov., 13:02, Desmond Lee <m...@xxxxxx> wrote:
Quote:

> Justin,
>
> One simple way is to use Control Panel > Scheduled Task to call a batch file
> (*.bat or *.cmd) that will launch the actual *.ps1 script. Make sure that the
> account has the right credentials to connect and function remotely on the
> target machine.
>
> Hope this helps. Do let us know. Thanks!
>
> --http://www.leedesmond.com/weblog/
>
> "Justin Rich" wrote:
Quote:

> > i just wrote a script to do backups (with an imaging product) and now i want
> > to make a script to deploy this and there are two things i need to do that
> > im not really sure how to do.
>
Quote:

> > 1) create a schedule task with WMI (i want wmi so i can do it remotely)
> > 2) create an account and add it to the admin group
> > 3) modify the remote systems path enviornment var. (not a must, but would be
> > nice)
My System SpecsSystem Spec
Old 11-26-2007   #4 (permalink)
Shay Levi


 
 

Re: schedule a task with WMI?

You can also schedule the task with schtasks.exe:

schtasks /s <computerName> /create /sc minute /mo 10 /tn "PowerShell Script"
/tr "C:\WINDOWS\system32\WINDOW~1\v1.0\powershell.exe c:\scripts\yourScript.ps1"
/ru <username> /rp <password>

More examples can be found here:
http://www.microsoft.com/resources/d....mspx?mfr=true



-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com


Quote:

> i just wrote a script to do backups (with an imaging product) and now
> i want to make a script to deploy this and there are two things i need
> to do that im not really sure how to do.
>
> 1) create a schedule task with WMI (i want wmi so i can do it
> remotely)
> 2) create an account and add it to the admin group
> 3) modify the remote systems path enviornment var. (not a must, but
> would be
> nice)

My System SpecsSystem Spec
Old 11-26-2007   #5 (permalink)
Shay Levi


 
 

Re: schedule a task with WMI?

For your second request see Brandon's function ("Re: Windows XP, Users and
Groups" thread)

function Add-UsertoLocalGroup{
Param([string]$user,[string]$group,[string]$server)
If(!($server)){$server = get-content env:COMPUTERNAME}
Write-Host "Adding User [$user] to group [$group]"
Write-Host "----------------------------------------------" -ForegroundColor
gray
$srv = [ADSI]("WinNT://$server,computer")
$u = [ADSI]("WinNT://$server/$User,User")
# Getting Group and Adding User
$g = [ADSI]("WinNT://$server/$group,group")
$g.psbase.invoke("add",$u.psbase.path)
}


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com


Quote:

> i just wrote a script to do backups (with an imaging product) and now
> i want to make a script to deploy this and there are two things i need
> to do that im not really sure how to do.
>
> 1) create a schedule task with WMI (i want wmi so i can do it
> remotely)
> 2) create an account and add it to the admin group
> 3) modify the remote systems path enviornment var. (not a must, but
> would be
> nice)

My System SpecsSystem Spec
Old 11-26-2007   #6 (permalink)
Shay Levi


 
 

Re: schedule a task with WMI?

I wrote a blog post on "Creating Environment variables", its for local use,
I'll try to find a way to do it remotely:

http://scriptolog.blogspot.com/2007/...variables.html


-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com


Quote:

> i just wrote a script to do backups (with an imaging product) and now
> i want to make a script to deploy this and there are two things i need
> to do that im not really sure how to do.
>
> 1) create a schedule task with WMI (i want wmi so i can do it
> remotely)
> 2) create an account and add it to the admin group
> 3) modify the remote systems path enviornment var. (not a must, but
> would be
> nice)

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Rename schedule task VB Script
Task Schedule batch file Vista General
Schedule a task with Vista task Scheduler wakes up computer and mo Vista General
Schedule Task Vista performance & maintenance
schedule task in powershell 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