The term 'psexec.exe' is not recognized as the name of a cmdlet, function, scrip

This topic contains 6 replies, has 3 voices, and was last updated by Profile photo of Arie H Arie H 8 months, 3 weeks ago.

  • Author
    Posts
  • #35969
    Profile photo of Uttam Kumar Mohanta
    Uttam Kumar Mohanta
    Participant

    Hi All,

    I am tryng to run a powershell command from powershell DSC. Following is my script.
    My command is placed in "C:\TestBat.bat".

    It is giving error as title line(The term 'psexec.exe' is not recognized as the name of a cmdlet, function, scrip).

    Please help me

    Configuration TestCmdExe
    {
    Node NodeName
    {
    Script ExecuteCmdInBatFle
    {
    GetScript = { return $false }
    TestScript = { return $false }
    SetScript =
    {
    Write-Verbose "STARTING"
    & psexec.exe -s C:\TestBat.bat
    Write-Verbose "DONE"
    }
    }
    }
    }
    TestCmdExe
    Start-DscConfiguration -Path .\TestCmdExe -Verbose -Wait -Force

  • #35971
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    presumably, psexec.exe is not found on the $env:PATH variable for the LocalSystem account (which is what DSC runs under).

    However, all "psexec.exe -s" does is run something in the systme context anyway, so you can probably get away with just: & c:\TestBat.bat .

    However, that's going to run the batch file _every_ time DSC applies its configuration, and I'm not sure that's something I'd ever want to happen. Instead I'd be looking into converting whatever's in that batch file over to PowerShell and DSC resources that can be set up individually.

  • #35977
    Profile photo of Uttam Kumar Mohanta
    Uttam Kumar Mohanta
    Participant

    Thank you very much Dave. It worked for me.
    I tried with & C:\TestBat.bat
    instead of
    & psexec.exe -s C:\TestBat.bat.

  • #36683
    Profile photo of Uttam Kumar Mohanta
    Uttam Kumar Mohanta
    Participant

    ..

    Uttam Kumar Mohanta

    March 18, 2016 at 3:42 am / #36699
    .
    Hello All,

    I am running a bat file by powershell dsc as below. It was working fine few days back but suddenly it stopped working and throwing below error.
    Please hellp me to get it resolve.

    Code:
    Configuration RunBatFile
    {
    Node Node1
    {
    Script ExecuteBatFile
    {
    GetScript = { return $false }
    TestScript = { return $false }
    SetScript =
    {
    Write-Verbose "STARTING..."
    & C:\Testing.bat
    Write-Verbose "DONE"
    }
    }
    }
    }
    RunBatFile
    Start-DscConfiguration -Path .\RunBatFile -Verbose -Wait -Force

    Error:
    The PowerShell DSC resource MSFT_ScriptResource threw one or more non-terminating errors while running the
    Set-TargetResource functionality. These errors are logged to the ETW channel called
    Microsoft-Windows-DSC/Operational. Refer to this channel for more details.
    + CategoryInfo : InvalidOperation: (:) [], CimException
    + FullyQualifiedErrorId : NonTerminatingErrorFromProvider
    + PSComputerName : ComputerName

    The SendConfigurationApply function did not succeed.
    + CategoryInfo : NotSpecified: (root/Microsoft/...gurationManager:String) [], CimException
    + FullyQualifiedErrorId : MI RESULT 1
    + PSComputerName : ComputerName

  • #36704
    Profile photo of Dave Wyatt
    Dave Wyatt
    Moderator

    You'll need to look at the error in your DSC event log for more information.

  • #36818
    Profile photo of Uttam Kumar Mohanta
    Uttam Kumar Mohanta
    Participant

    Hi Dave,
    Here is the log. Please help on this.

    Job {31CFD051-F015-11E5-80DC-0050568F384F} :
    This event indicates that a non-terminating error was thrown when DSCEngine was executing Set-TargetResource on MSFT_ScriptResource DSC resource. FullyQualifiedErrorId is NativeCommandError. ErrorMessage is 'rmqservice' is not recognized as an internal or external command,.

  • #36821
    Profile photo of Arie H
    Arie H
    Participant

    What is exactly written in the batch file ?

You must be logged in to reply to this topic.