Trying to get A batrch file to run from a PS script that displays to the screen

Home Forums Scripting PowerShell Trying to get A batrch file to run from a PS script that displays to the screen

Viewing 1 post (of 1 total)
  • Author
    Posts
  • Avatar
    jason0923
    Member
    #166840

    I have a powershell script to query a CSV and then if … run a batch file. When I run the Script manually it does what I need and displays the batch file on the screen for the user to see. I’m trying to get it to run as a scheduled task and the task runs but the batch file (which requires user interaction) doesn’t display. Is there some command in either the PS or Batch I need when run as a scheduled task?

    PS Script:

    set-executionpolicy unrestricted
    $hostname = hostname
    $csv = “c:user datashutdown.Csv”
    $check = (Import-Csv $csv).”Computername”
    $check -contains “$hostname”
    $check2 = $check -contains “$hostname”

    If($check2 -eq$true){start-process ‘c:user dataask.cmd’
    }

    Batch File:

    [USER=”68995″]Echo[/USER] OFF
    :myLabel
    Color 0E
    SHUTDOWN /S /F /T 600
    SET /P continue=”Your computer is about to shutdown in 10 min do you want to abort (y/n): “
    IF %continue% EQU y (
    SHUTDOWN /A
    )

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.