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

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

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.

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

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: (:slight_smile: [], CimException
  • FullyQualifiedErrorId : NonTerminatingErrorFromProvider
  • PSComputerName : ComputerName

The SendConfigurationApply function did not succeed.

  • CategoryInfo : NotSpecified: (root/Microsoft/…gurationManager:String) [], CimException
  • FullyQualifiedErrorId : MI RESULT 1
  • PSComputerName : ComputerName

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

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,.

What is exactly written in the batch file ?