Extracting, modifying and transfering info from 1 file to another

(imported topic written by FITZPAW91)

Hi All

I have about 60 HP servers that have the wrong ILO name or domain name. I have a Task that gets this information for me and puts it in a text file. I want to grab some of the information, correct the ILO name and Domain Name with information taken from the Windows Operating system, then put all this information back in a different file.

Here is an example that is output by HPONCFG.exe

<DIR_INFO MODE=“write”>

<MOD_DIR_CONFIG>

<DIR_AUTHENTICATION_ENABLED VALUE = “N”/>

<DIR_LOCAL_USER_ACCT VALUE = “Y”/>

<DIR_SERVER_ADDRESS VALUE = “”/>

<DIR_SERVER_PORT VALUE = “636”/>

<DIR_OBJECT_DN VALUE = “”/>

<DIR_OBJECT_PASSWORD VALUE = “”/>

<DIR_USER_CONTEXT_1 VALUE = “”/>

<DIR_USER_CONTEXT_2 VALUE = “”/>

<DIR_USER_CONTEXT_3 VALUE = “”/>

</MOD_DIR_CONFIG>

</DIR_INFO>

<RIB_INFO MODE=“write”>

<MOD_NETWORK_SETTINGS>

<SPEED_AUTOSELECT VALUE = “N”/>

<NIC_SPEED VALUE = “100”/>

<FULL_DUPLEX VALUE = “Y”/>

<DHCP_ENABLE VALUE = “N”/>

<DHCP_GATEWAY VALUE = “Y”/>

<DHCP_DNS_SERVER VALUE = “Y”/>

<DHCP_STATIC_ROUTE VALUE = “Y”/>

<DHCP_WINS_SERVER VALUE = “Y”/>

<REG_WINS_SERVER VALUE = “Y”/>

<IP_ADDRESS VALUE = “10.8.11.76”/>

<SUBNET_MASK VALUE = “255.255.255.0”/>

<GATEWAY_IP_ADDRESS VALUE = “10.8.11.254”/>

<DNS_NAME VALUE = “WrongComputerName”/> This is information to change, it will never be the same

<DOMAIN_NAME VALUE = “WrongDomainName.com”/> This is information to change, it will never be the same

<PRIM_DNS_SERVER value = “10.10.10.40”/>

<SEC_DNS_SERVER value = “10.10.10.41”/>

<TER_DNS_SERVER value = “0.0.0.0”/>

<PRIM_WINS_SERVER value = “10.10.10.40”/>

<SEC_WINS_SERVER value = “10.10.10.41”/>

<STATIC_ROUTE_1 DEST = “0.0.0.0” GATEWAY = “0.0.0.0”/>

<STATIC_ROUTE_2 DEST = “0.0.0.0” GATEWAY = “0.0.0.0”/>

<STATIC_ROUTE_3 DEST = “0.0.0.0” GATEWAY = “0.0.0.0”/>

</MOD_NETWORK_SETTINGS>

</RIB_INFO>

<USER_INFO MODE=“write”>

</USER_INFO>

Now to fix my incorrect ILO Names, I need to create a file with the following information in it.

<RIB_INFO MODE=“write”>

<MOD_NETWORK_SETTINGS>

<DNS_NAME VALUE=“Correct Computer Name taken from BigFix”/> Computer Name

<DOMAIN_NAME VALUE=“ilo.Name Of Domaintaken from BigFix”/> observe, ilo. is added before domain name

</MOD_NETWORK_SETTINGS>

</RIB_INFO>

All help is appreciated.

Thanks

William

(imported comment written by BenKus)

Is this info pulled from the local client? You could so something like this:

<DNS_NAME VALUE="{computer name}"/>
<DOMAIN_NAME VALUE=“ilo.{dns name}”/>

Ben

(imported comment written by FITZPAW91)

Thanks Ben

But, DNS NAME returns the FQDN, and I only need the name of the workgroup or domain that the client is in. I haven’t been able to find a property that shows only this information. To get this informaiton, I know I can use

following text of first “.” of DNS Name

I seem to have most of the pieces, I just need help bringing it all together, as in how would I pull only the lines I need and insert them into a brand new file? And then change those lines to the changes mentionned previously.

What i need is the action code to do this.

Thanks

William

(imported comment written by BenKus)

I think you can use this for the workgroup:

string value of selects “Domain from Win32_ComputerSystem” of wmi

See here for assistance replacing text in files…

Ben