Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

gwmi Win32_ScheduledJob | gm

68 views
Skip to first unread message

IT Staff

unread,
Aug 21, 2008, 4:32:35 AM8/21/08
to
The above does not work ?

I m trying to use powershell and *remotely* create a schedule on remote
machine ...any idea ?


/\/\o\/\/ [MVP]

unread,
Aug 21, 2008, 5:00:05 AM8/21/08
to
IT Staff,

it does work only I think you do not have any scheduled jobs yet.

to create a job, you need the Class, not the list of instances.

you can use the typeadapter [wmiClass for this and then use the Create
methoid :

PS C:\Users\mvanorsouw> ([wmiclass]'Win32_ScheduledJob').create


MemberType : Method
OverloadDefinitions : {System.Management.ManagementBaseObject
Create(System.String Command, System.
String StartTime, System.Boolean RunRepeatedly,
System.UInt32 DaysOfWeek, Sys
tem.UInt32 DaysOfMonth, System.Boolean
InteractWithDesktop)}
TypeNameOfValue : System.Management.Automation.PSMethod
Value : System.Management.ManagementBaseObject
Create(System.String Command, System.S
tring StartTime, System.Boolean RunRepeatedly,
System.UInt32 DaysOfWeek, Syst
em.UInt32 DaysOfMonth, System.Boolean
InteractWithDesktop)
Name : Create
IsInstance : True

Greetings /\/\o\/\/
http://thePowerShellGuy.com

IT Staff

unread,
Aug 21, 2008, 5:09:02 AM8/21/08
to
I created a job *manually* ...how do i retrieve it ?


"/\/\o\/\/ [MVP]" <oM...@discussions.microsoft.com> wrote in message
news:66B57D69-D1BE-4A35...@microsoft.com...

/\/\o\/\/ [MVP]

unread,
Aug 21, 2008, 5:31:00 AM8/21/08
to
When I create a job this way, I can retrieve it :

PS C:\Windows\System32>
([wmiclass]'Win32_ScheduledJob').create('Ipconfig','********143000.000000-420',$true,1
,$null,$false)


__GENUS : 2
__CLASS : __PARAMETERS
__SUPERCLASS :
__DYNASTY : __PARAMETERS
__RELPATH :
__PROPERTY_COUNT : 2
__DERIVATION : {}
__SERVER :
__NAMESPACE :
__PATH :
JobId : 1
ReturnValue : 0
Properties : {JobId, ReturnValue}
SystemProperties : {__GENUS, __CLASS, __SUPERCLASS, __DYNASTY...}
Qualifiers : {}
ClassPath : __PARAMETERS
Site :
Container :

PS C:\Windows\System32> gwmi win32_scheduledjob


JobId : 1
Name :
Owner :
Priority :
Command : Ipconfig

B.T.W. did you use SchTask or AT (that works different) to schedule your job ?

Enjoy,

Marco Shaw [MVP]

unread,
Aug 21, 2008, 12:44:47 PM8/21/08
to
IT Staff wrote:
> I created a job *manually* ...how do i retrieve it ?

The problem with scheduled jobs is that you have to create *and* view
the job with the same "technology". You can only use WMI to view jobs
that were created using WMI...

You could consider using WinRM's winrs command to call the command
remotely, depending on whether you're using it in your environment.

Marco

--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com

0 new messages