Start-job with datetime arguments

Hi,
It is working (of course), I get all objects which are newer then $timeFrom:
$timeFrom = "2014-03-25 9:00"
Get-ChildItem c:\temp | ?{$_.CreationTime -gt $timeFrom}
But is not working:
$timeFrom = "2014-03-25 9:00"
Start-Job -ScriptBlock {Get-ChildItem c:\temp | ?{$_.CreationTime -gt $args[0]}} -ArgumentList @($timeFrom)
I get all objects, but if I replace -gt to -lt the list will be empty. Teherefore any kind of compare working, but I can't understand how...
Anybody can help me?

When you're using variables defined outside of the scriptblock you have to pass them into the scriptblock.  I prefer to keep them all the same just because it's easier to understand for me.  Yours probably would have worked if you'd included the
param part:
Start-Job -ScriptBlock {param($args)Get-ChildItem c:\temp | ?{$_.CreationTime -gt $args[0]}} -ArgumentList
@($timeFrom)
but I'm not sure whether or not using $args works at all in this context.  It probably does, but without param it definitely wouldn't.
I hope this post has helped!

Similar Messages

  • Unable to start-job with credentials

    I cannot get any jobs to run while using the credential parameter and I'm absolutely sure the credentials are correct. Has anyone had this issue?
    PS C:\Windows\system32> Start-Job -credential $creds -scriptblock {start-sleep 10}
    Id              Name            State      HasMoreData     Location             Command
    1               Job1            Failed     False           localhost            start-sleep 10
    Dan

    Same result with version 3. 
    PS H:\> start-job -name newjob1 -Credential $credential -ScriptBlock {start-sleep 10}
    Id     Name            PSJobTypeName   State         HasMoreData     Location             Command
    8      newjob1         BackgroundJob   Failed        False           localhost            start-sleep 10
    PS H:\> (get-job -name newjob1).ChildJobs[0].JobStateInfo |fl
    State  : Failed
    Reason : System.Management.Automation.Remoting.PSRemotingTransportException: There is an error launching the
             background process. Error reported: The directory name is invalid. ---> System.ComponentModel.Win32Exception:
             The directory name is invalid
                at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
                at System.Management.Automation.Runspaces.PowerShellProcessInstance.Start()
                at System.Management.Automation.Remoting.Client.OutOfProcessClientSessionTransportManager.CreateAsync()
                --- End of inner exception stack trace ---
    Dan

  • Cannot start job with Management Console

    Hi,
    The Management Console displays the status of batch jobs started with DI Designer, but when attempting to run a  batch job via the Management Console nothing happens.
    The execute command displays "Job started successfully", but does nothing.
    Any ideas would be appreciated.
    Thanks in advance.
    Regards,
    Meet

    Hi Meet,
    Do execute the job again from Central Management Console and go to following path
    C:\ProgramData\SAP BusinessObjects\Data Services\log
    Here in the log folder you will find those many number of folders with job server names as there are job servers in your server.
    Go to the respective job server folder(which is used to run your particular job).
    In this folder you can find, all the repository folders associated with that job server.
    Go to the respective repository in which you have the job.
    Here comes the best part.In this repository folder Data services created 6 files for every job execution, which are
    ERROR_DATE_NUMBER(.txt,and .idx)
    MONITOR_DATE_NUMBER(.txt and .idx)
    TRACE_DATE_NUMBER(.txt and .idx)
    Open the trace.txt file which has been created recently.(check date and time after running your job).
    Now this file will tell you whether the job has been executed, started and stopped due to some error or never executed.
    Case1:
    If there's a trace.txt file then job had started
    Case2:
    If it executed successfully then you will find the start and end time stamps in the trace.txt file.
    Case3:
    If there's an error, open the recent error.txt file, you'll find the error log!!
    Hope this will help you. Do update the status of your issue!!
    Regards,
    Mubashir Hussain

  • Creating a job with arguments

    Hi,
    This might sound really remedial, but can someone explain to me how I go about creating a job with arguments with programs. It errors out when I try to use DEFINE_PROGRAM_ARGUMENTS and when I try to use SET_JOB_ARGUMENTS_VALUE. Maybe it's the order I do it in. Any directions would be much appreciated. Thanks!
    Tony

    Hi Tony,
    Almost any internal error is an Oracle bug and you should report this to support.
    This is definitely not supposed to happen and I haven't seen this error before, do you have a test case throwing the error ?
    Using program arguments should be fairly straightforward. Here's a simple example with two varchar2 arguments
    -- create a stored procedure with two arguments
    create or replace procedure myproc (arg1 in varchar2, arg2 in varchar2)
    is BEGIN null; END;
    -- create a program with two arguments and define both
    begin
    dbms_scheduler.create_program
    program_name=>'myprog',
    program_action=>'myproc',
    program_type=>'STORED_PROCEDURE',
    number_of_arguments=>2, enabled=>FALSE
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT(
    program_name=>'myprog',
    argument_position=>1,
    argument_type=>'VARCHAR2',
    DEFAULT_VALUE=>'13');
    dbms_scheduler.DEFINE_PROGRAM_ARGUMENT(
    program_name=>'myprog',
    argument_position=>2,
    argument_type=>'VARCHAR2');
    dbms_scheduler.enable('myprog');
    end;
    -- create a job pointing to a program and set both argument values
    begin
    dbms_scheduler.create_job('myjob',program_name=>'myprog');
    dbms_scheduler.set_job_argument_value('myjob',1,'first arg');
    dbms_scheduler.set_job_argument_value('myjob',2,'second arg');
    dbms_scheduler.enable('myjob');
    end;
    Hope this helps,
    Ravi.
    -Ravi

  • On start up my Mac Book Pro shows a white screen with a spinning wheel. I have tried starting up with the Snow Leopard disk - all I get is a blue screen. I guess that this is a major repair job??????

    On start up my Mac Book Pro shows a white screen with a spinning wheel. I have tried starting up with the Snow Leopard disk - all I get is a blue screen. I guess that this is a major repair job??????

    If you have the exact same problem - take the computer to an Apple store or an AASP.  Whichever is more convenient for you.  If you have AppleCare call them!

  • Background job with immediate start

    Hi,
    In my program, I have to create a background job with immediate start. I used function module 'BP_JOB_CREATE', but it does not start immediately.
    Can anybody provide sample code for immediate job start.
    Regards,
    Nitin

    Hi,
    Use these function modules.
    JOB_OPEN
    JOB_SUBMIT
    JOB_CLOSE
    in JOB_SUBMIT function module u can pass to start the job immediately in export parameters PRIPARAMS structure  field name PRIMM which has to be set to 'X' to start immediately.
    regards,
    Santosh Thorat

  • Start weblogic server with java argument

    Hello,
    I am using weblogic server version 10.2. And the environment have one Admin server and two machines.
    In admin console, one managed sever is configured with Java argument in "Server Start". The java option can be passed to JVM when i start the managed server in admin console. i confirmed that by execute ps the java process from the linux server. However, the java argument cannot pass to the JVM when i start from command line as below. is there any specific configuration required?
    /weblogic/bea102/wlserver_10.0/common/bin/wlscontrol.sh -d premium_102_internet_qa -n /weblogic/ndmgr -c -f startManagedWebLogic.sh -s server_qa_svra START
    PLease help!
    Thanks,
    Angus

    You have to use the nodemanager. The parameters are added to a file startup.properties, located in the
    directory: <middleware-home>/user_projects/domains/<domain-name>/servers/<server-name>/data/nodemanager
    The file startup.properties is used by the nodemanager to start your managed server.
    You can start your environment by using a start script (written using WLST), for example,
    beahome = '<middleware-hoem>';
    adminusername = 'username';
    adminpassword = 'password';
    domainname = 'domain-name';
    linux = true;
    pathseparator = '/';
    if not linux:
         pathseparator = '\\';
    domainlocation = beahome + pathseparator + 'user_projects' + pathseparator + 'domains' + pathseparator + domainname;
    nodemanagerhomelocation = beahome + pathseparator + 'wlserver_10.3' + pathseparator + 'common' + pathseparator + 'nodemanager';
    print 'START NODE MANAGER';
    startNodeManager(verbose='true', NodeManagerHome=nodemanagerhomelocation, ListenPort='5556', ListenAddress='localhost');
    print 'CONNECT TO NODE MANAGER';
    nmConnect(adminusername, adminpassword, 'localhost', '5556', domainname, domainlocation, 'ssl');
    print 'START ADMIN SERVER';
    nmStart('AdminServer');
    nmServerStatus('AdminServer');
    print 'CONNECT TO ADMIN SERVER';
    connect(adminusername, adminpassword);
    print 'START MANAGED SERVER';
    start('ServerName','Server');
    nmServerStatus('ServerName');

  • Multidimensional array with start-job

    Hi! I'm trying to improve a script that will read in a CSV file to an array, divide it up to 4 chunks. So I will have 4 arrays and inside each array I have properties for computername, ip addresses and so forth. ($arrComputers[0][56].ComputerName)
    So what I want to do is:
    # Send 1 chunk array at a time to a Start-Job. 1 chunk consits of 100 computers.
    # Read each object,  $arrComputers[index][row].Status ,
    # If Status says "OK" don't continue to check, Else continue to fetch info and write back to
    $arrComputers[index][row].<property>
    So for I've only gotten to 
    $Script={
    Param($comp)
    <Do Check, Read and Write for each computer here>
    for($i=0;$i -lt 4;$i++)
    $compCollection[$i] | Start-Job -ScriptBlock $Script -ArgumentList ($compCollection[$i]
    I hope I have been clear what I'm trying to do. This is my first time trying it, so wouldn't surprise me if you guys got a better idea how to achieve what I want or what I've done wrong. I'm all ears and also to pointers to guides and such where I can read
    up more about advanced powershelling. 

    $computerlist | 
         ForEach-Object{
             Start-Job -Script $script
    -ArgumentList $_
    but
    $script={Param($computer)
    if($computer.Status -eq "OK"){
    #Do Nothing
    else
    #Do Something
    $computer.Status = #Assign new value
    #write back the same chunk it derived from.
    for($i=0;$i -lt 4;i++){
    $computerlist[$i] |
    ForEach-Object{
    Start-Job -Script $script -ArgumentList $_

  • Reports-Job-Scheduler: create job with startoption later: wrong date-format

    Hi,
    I test reports 11.1.1.2.0 (weblogic11 g) and try to start a report job with Reports-Job-Scheduler.
    Startoption: later and date = 09:48 Jan 12, 2010
    When I submit the job I get following Error:
    REP-50006: Das Argument SCHEDULE ist in der Befehlszeile ungültig: 09:48 Jän 12, 2010
    in english:
    Rep-50006: argument Schedule is wrong in command line: 09:48 Jän 12, 2010
    Why is Jän instead of Jan.
    When I start the report in February then it works.
    I defined also environment variables in basic configuration for the report server:
    NLS_DATE_FORMAT DD.MM.YYYY
    NLS_DATE_LANGUAGE GERMAN
    NLS_LANG GERMAN_GERMANY.WE8ISO8859P1
    I would be very pleased to get support.
    Many thanks
    Alois

    I created a SR and oracle support found a bug in EM.

  • How to use Start-Job?

    Hello folks,
    I am trying to setup a simple Start-Job command.  This basic command works for me and copies the file correctly.
    Start-Job -Scriptblock {Copy-Item -Path \\192.168.32.25\share\butterfly.jpg -Destination c:\test\ -Recurse -Verbose}
    However, it does not work when I try using variable like this.
    $source = "\\192.168.32.25\share\butterfly.jpg"
    $target = "c:\test\"
    Start-Job -Scriptblock {Copy-Item -Path $source -Destination $target -Recurse -Verbose}
    Anyone have suggestions for getting this to work with variables?
    Thanks,
    romatlo

    Hi,
    Here's some information:
    http://powershell.org/wp/forums/topic/passing-parameter-to-start-job/
    https://social.technet.microsoft.com/Forums/scriptcenter/en-US/ff644fca-1b25-4c8a-9a8a-ce90eb024389/in-powershell-how-do-i-pass-startjob-arguments-to-a-script-using-param-style-arguments?forum=ITCG
    Basically, look at using -ArgumentList:
    http://ss64.com/ps/start-job.html
    Don't retire TechNet! -
    (Don't give up yet - 13,225+ strong and growing)

  • Jobs with a startevent and starttime

    hello,
    I'd like to plan a job in an abap program which is started when an event is raised or a certain timespan
    has passed.
    When planing the job by using the functionmodules job_open, job_submit and and job_close I can supply an event and a startdate but the implementation of the functionmodules ignores the event when the startdate parameter is supplied.
    Is there a workaround to enable event triggered jobs with a startdate which is used if the event is not raised within a certain timespan or do I really hav to use 2 jobs?
    thanks
    Roman

    Hello Roman
    I think you have to use 2 jobs, but if you use 2 jobs with the same program the program may run twice.
    You could create 1 job with your program that is started by event and 1 job with a startdate/time that runs a program that raise the event.
    best regards
    Thomas Madsen Nielsen

  • Schedule Job with Job_close after successful job doesn't work

    Hi guys,
    I'm using FM CLOSE_JOB with parameters : 
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName
    I have about 9 jobs wich must run the one after the others. The first start without PRED* parameters, but the 8 others one are filled with CHECKSTAT, and previous job name and id.
    It works fine for the side "the one after the others", BUT, wathever the previous job give as result (cancelled or finished), the next one starts whereas I pass the parameter CHECKSTAT to X.
    Any ideas of the problem and how to solve it?
    Thanks in advance for your answers.

    Here my code with explanation :
    REPORT  YCOMJ023.
    start-of-selection.
    "Initialization of my vars
    w_StepCount = 0. >> number of steps maxi in a job
    w_jobCount = 1.  >> number to see easier in SM37 the job order
    CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName. (example : TOTO_STEP1)
    CONDENSE w_JobName NO-GAPS.
    "I open my first job
      CALL FUNCTION 'JOB_OPEN' (OPEN job TOTO_STEP1)
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobID
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    "We keep in memory first job IDs to close it at the end of the prg
      w_firstjobName = w_JobName.
      w_firstjobID = w_JobID.
    "imagine you do the bellow code in a loop and it makes several jobs TOTO_STEP2 TOTO_STEP3 TOTO_STEP4...
    ADD 1 TO w_StepCount.
    IF w_StepCount GT 250.
        "I call close job eatch time I reach 250 steps
         PERFORM fx_jobclose.
    ENDIF.
    submit RKGALKEUB to sap-spool and return
                                       without spool dynpro
                                       spool parameters print_parameters
                                            VIA JOB w_JobName NUMBER w_JobID
    "End of the programmI close the current Job and the first one :
    "Current
            CALL FUNCTION 'JOB_CLOSE'
              EXPORTING
                JOBCOUNT             = w_JobId
                JOBNAME              = w_JobName
                PREDJOB_CHECKSTAT    = 'X'
                PRED_JOBCOUNT        = w_oldJobId
                PRED_JOBNAME         = w_oldJobName.
    "First one + launch with STRIMMED
            CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_firstjobId
              JOBNAME              = w_firstjobName
              STRTIMMED            = 'X'
            EXCEPTIONS
              cant_start_immediate = 1
              invalid_startdate    = 2
              jobname_missing      = 3
              job_close_failed     = 4
              job_nosteps          = 5
              job_notex            = 6
              lock_failed          = 7
              OTHERS               = 8.
    *&      Form  fx_jobclose
    *       text
    FORM fx_jobclose.
      "Step to zero to do a new loop after this form
      w_StepCount = 0.
      DATA : w_job_released TYPE CHAR1.
      "If the flag IsFirst, we don't do nothing, because it's the first JOb, and it should not be closed
      IF w_IsFirst = 'X'.
        "Flag is set to blank
        w_IsFirst = ''.
      ELSE.
          "Else it mean we are closing a job with predecessor :
          CALL FUNCTION 'JOB_CLOSE'
            EXPORTING
              JOBCOUNT             = w_JobId
              JOBNAME              = w_JobName
              PREDJOB_CHECKSTAT    = 'X'
              PRED_JOBCOUNT        = w_oldJobId
              PRED_JOBNAME         = w_oldJobName
              "SDLSTRTDT            = sy-datum
              "SDLSTRTTM            = sy-timlo
            IMPORTING
              JOB_WAS_RELEASED = w_job_released.
      ENDIF.
      "Vars get the value of current job, witch will become the older one
      w_oldJobId = w_jobID.
      w_oldJobName = w_JobName.
    "I make the new TOTO_STEPX job name
      ADD 1 TO w_jobCount.
      w_jobCountC = w_jobCount.
      CONCATENATE pe_name '_STEPS' w_jobCountC INTO w_JobName.
      CONDENSE w_JobName NO-GAPS.
      "I open the new job
      CALL FUNCTION 'JOB_OPEN'
        EXPORTING
          jobname          = w_JobName
        IMPORTING
          jobcount         = w_JobId
        EXCEPTIONS
          cant_create_job  = 1
          invalid_job_data = 2
          jobname_missing  = 3
          OTHERS           = 4.
    ENDFORM.                    "fx_jobclose
    I hope my code is clear enought, I tried to delete the superfluities code.

  • Error generating report job with the task name 'FSRM_Report_Task

    Since this morning we have been having a problem with FSRM on Windows Server 2008 R2, it is no longer running storage reports (both scheduled and on-demand).
    We get the following in the event logs:
    Log Name:      Application
    Source:        SRMREPORTS
    Date:          09/06/2014 08:09:55
    Event ID:      752
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      FILESERVER2.curriculum.riddlesdown.local
    Description:
    Error generating report job with the task name 'FSRM_Report_Task{3add1760-4e79-4141-baba-cb53391bef3e}'.
    Context:
     - Exception encountered = Invalid argument: StorageType = '101'
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="SRMREPORTS" />
        <EventID Qualifiers="0">752</EventID>
        <Level>2</Level>
        <Task>0</Task>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2014-06-09T07:09:55.000000000Z" />
        <EventRecordID>42920</EventRecordID>
        <Channel>Application</Channel>
        <Computer>FILESERVER2.curriculum.riddlesdown.local</Computer>
        <Security />
      </System>
      <EventData>
        <Data>Error generating report job with the task name 'FSRM_Report_Task{3add1760-4e79-4141-baba-cb53391bef3e}'.
    Context:
     - Exception encountered = Invalid argument: StorageType = '101'
    </Data>
      </EventData>
    </Event>
    We have uninstalled and reinstalled the FSRM role service but are still having the same problem.
    Anybody have any ideas?

    Hi,
    From the error message, it failed because of "invalid argument: storagetype = '101' ".
    101 means the storage type is "system" + "cache". Is there any change on your storage before the issue occurs? For example whether the source storage is changed?
    FsrmStorageModuleType enumeration
    http://msdn.microsoft.com/en-us/library/dd392346(v=vs.85).aspx
    If you have any feedback on our support, please send to [email protected]

  • Schedule job with JOB_CLOSE until a certain time

    Hello all,
    I'd like to schedule a background job with JOB_CLOSE until a certain time, i.e. first start time at 10 a.m., repitition period 15 min., last start time 1 p.m.
    I tried this using parameter LASTSTRTTM, e.g.:
    i_startdate = sy-datum.
    i_starttime = '100000'.
    i_prdmins = '15'.
    i_laststrtdt = sy-datum.
    i_laststrttm = '130000'.
    CALL FUNCTION 'JOB_CLOSE'
        EXPORTING
          jobcount             = l_jobcount
          jobname              = 'MY_JOB'
          sdlstrtdt            = i_startdate
          sdlstrttm            = i_starttime
          laststrtdt           = i_laststrtdt
          laststrttm           = i_laststrttm
          prdmins              = i_prdmins
        EXCEPTIONS
          cant_start_immediate = 1
          invalid_startdate    = 2
          jobname_missing      = 3
          job_close_failed     = 4
          job_nosteps          = 5
          job_notex            = 6
          lock_failed          = 7
          OTHERS               = 8.
    but I didn't succeed - the job didn't stop at 1 p.m. Any hints?
    Best regards
    Martin Lehmann

    Hi Martin,
    i_startdate = sy-datum.  " 1st time Job Start Date
    i_starttime = '100000'.
    i_prdmins = '15'.
    i_laststrtdt = sy-datum.  " If Job is not started by this date, then it wont be started once this date is completed
    i_laststrttm = '130000'.
    What it means is, if i want to start a job by 10th Oct.. & expect that it should be started maximum by 20th Oct.. If its 20th Oct & still the job is not started,... then terminate the job & do not start it..
    If the job is already started, then it wont stop.
    Hope its clear.
    Best regards,
    Prashant

  • PowerShell using start job to run multiple code blocks at the same time

    I will be working with many 1000’s of names in a list preforming multiple function on each name for test labs.
    I notice when it is running the functions on each name I am using almost no CPU or memory.  That led me to research can I run multiple threads at once in a PowerShell program. That lead me to articles suggesting start-job would do just want I am looking
    for. 
    As a test I put this together.  It is a simple action as an exercise to see if this is indeed the best approach.  However it appears to me as if it is still only running the actions on one name at a time.
    Is there a way to run multiple blocks of code at once?
    Thanks
    Start-Job {
    $csv1 = (Import-Csv "C:\Copy AD to test Lab\data\Usergroups1.csv").username
    foreach ($name1 in $csv1) { Write-Output "Job1 $name1"}
    Start-Job {
    $csv2 = (Import-Csv "C:\Copy AD to test Lab\data\Usergroups2.csv").username
    foreach ($name2 in $csv2) { Write-Output " Job2 $name2"}
    Get-Job | Receive-Job
    Lishron

    You say your testing shows that you are using very little cpu or memory in processing each name, which suggests that processing a single name is a relatively trivial task.  
    You need to understand that using a background job is going to spin up another instance of powershell, and if you're going to do that per name what used to require a relatively insignificant amount of memory is going to take around 60 MB.  
    Background jobs are not really well suited for multi-threading short-running, trivial tasks.  The overhead of setting up and tearing down the job session can be more than the task itself.
    Background jobs are good for long-running tasks.  For multi-threading short, trivial tasks runspaces or a workflow would probably be a better choice.
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

Maybe you are looking for

  • How do I get my data from my G3 onto a G4 QS?

    What is the easiest way to transfer my data to a newer G4? Can I take the hard drives out of the G3 and just add them to the G4? Or do I do it via firewire or ethernet. If I do use ethernet, do I need a crossover cable or a cat 5 cable? The G3 is a B

  • Sharepoint server issue:: Register Managed Account -Password supplied with username was not correct

    when i am creating a managed account from share point server admin it is showing:- The password supplied with the username fimservice was not correct. Verify that it was entered correctly and try again. i have put correct password but even though it

  • Console -f not working in ALOM

    Hi, I connected to ALOM on V240 installed with Solaris 10. console -f does not give me console on screen. Sun(tm) Advanced Lights Out Manager 1.6.8 sc> console -f Enter #. to return to ALOM. ...I pressed ENTER a lot of times but does not give me cons

  • How to fix "Adobe RoboHelp 7 has encountered a problem" error?

    I am using Adobe RoboHelp 7 to create WebHelp, with Windows XP. I haven't worked on my help project for about 10 days, and suddenly when I try to open the project I get this message: "Adobe RoboHelp 7 has encountered a problem and needs to close. We

  • What products have with my one year's pre-paid subscription?

    Hi, Very confusing and not very clear on what I products I actually have for my one year Creative Cloud Photography subscription. Have I missed something during the purchasing procedure? I had issues with loading Photoshop CC 2014, which are now solv