I m trying to use powershell and *remotely* create a schedule on remote
machine ...any idea ?
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
"/\/\o\/\/ [MVP]" <oM...@discussions.microsoft.com> wrote in message
news:66B57D69-D1BE-4A35...@microsoft.com...
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,
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