Ask Your Question

Convert Command Batch Files to Puppet

asked 2016-05-11 08:55:07 -0500

joshan gravatar image

We are trying to move all of our lockdown scripts from batch files to Puppet code, but I am not seeing much data on this. For instance how would I convert the bottom to Puppet Code? I knowI could reference the file with an exec command, but than it will run every 30 minutes.

Echo Disabling NetBT
@echo off
for /f "skip=1 tokens=1,2" %%m in ('wmic nicconfig where ^(tcpipnetbiosoptions^='1' or tcpipnetbiosoptions^='0'^) get index^, tcpipnetbiosoptions') do (
if /I %%m==No goto :Disable_NetBIOS
if %%n==0 (wmic nicconfig where index=%%m call SetTcpipNetBIOS 2 1>nul
) else (
if %%n==1 (wmic nicconfig where index=%%m call SetTcpipNetBIOS 2 1>nul

Echo Disabling WINS and LMHOST
wmic nicconfig call enablewins false, false
edit retag flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted

answered 2016-05-11 10:43:30 -0500

UBPClaw gravatar image

You could have your script log the output and use the creates function so that the script wont run again if that log file exists. The problem is that if WINS were to somehow become enabled after that your code wouldnt run.

Better option is to get the Registry module from the forge. Youll have to track down the registry keys associated with what youre doing, but at least itll keep your server in a consistent state

edit flag offensive delete link more


comment to long, see the answer i Posted

joshan gravatar imagejoshan ( 2016-05-11 11:42:13 -0500 )edit

answered 2016-05-11 11:43:13 -0500

joshan gravatar image

This would definitely work I appreciate the reply! However I have one more question maybe you can help with.

The Netbios key is stored in \SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces

Under thay key it lists the interfaces, which have a unique GUID. How could I do this in puppet since the GUID will be different on each server?

edit flag offensive delete link more



Probably best option would be a regex that acted as a catch all so settings would be applied to all interfaces. If you like my answer make sure to mark it as correct or accepted :)

UBPClaw gravatar imageUBPClaw ( 2016-05-11 12:30:02 -0500 )edit

answered 2016-05-18 19:39:32 -0500

In case others are looking for a resolution to a problem similar to this. I created a module that solves this particular issue. It combines a structured fact and iteration to get the job done.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-05-11 08:49:27 -0500

Seen: 55 times

Last updated: May 11 '16