I need to run a file.bat using DSC resources. The only way I was able to successfully execute the file.bat was by using the Package resource. However I receive the following error:
PowerShell DSC resource MSFT_PackageResource failed to execute Set-TargetResource functionality with error message: Package from Directory\To\MyFile\file.bat was installed, but the specified ProductId and/or Name does not match package details
I know the meaning of the error, and I have previously resolved it. However, there is no productId nor a Name for a batch file.
How else can I run a batch file using DSC?
$batch = @' ..code.. '@), then dump it to the file ($batch | Out-File -Encoding ascii -Force -FilePath 'X:\path\to\mybatch.cmd') and run using& .\mybatch.cmd. If this this doesn't work for you, then post more details about what's going wrong. - beatcrackerInvoke-Command -ScriptBlock {C:\choco\lib\elasticsearch\tools\elasticsearch-2.3.1\bin\service.bat install}andInvoke-Command -ScriptBlock {start C:\choco\lib\elasticsearch\tools\elasticsearch-2.3.1\bin\service.bat install}. However,Invoke-Command -ScriptBlock {& C:\choco\lib\elasticsearch\tools\elasticsearch-2.3.1\bin\service.bat install}worked. I assume& C:\choco\lib\elasticsearch\tools\elasticsearch-2.3.1\bin\service.bat installwould work, but I don't care. Thank you a bunch. - Samer