• Register
    • Login
    • Search
    • Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unsolved Hostname Change on 700+ Workstations

    FOG Problems
    6
    26
    3393
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      anthony.delarosa last edited by

      Server
      • FOG Version: 1.3.4
      • OS: CentOS 6.7
      Client
      • Service Version:
      • OS:
      Description

      Hello,

      We have a bit of a big project and that is that we are re-naming all workstations (previously imaged with FOG of course) to fit a better naming convention. Rather than doing this one by one as of course FOG can do with the FOG Hostname Changer, anything that FOG can do so that we can schedule this hostname change on 700+ workstations? Basically at the moment all PCs are named:

      vanprodz440-001, 002, 003 etc…

      We’d like to change that to van-wsz440a-001

      Any help would be greatly appreciated!
      Thanks FOG!

      1 Reply Last reply Reply Quote 0
      • A
        anthony.delarosa last edited by

        Thanks EVERYONE! this should give me enough information on getting 700+ updated and moved over to the correct OU although I didn’t really wanna start mucking around with the DB but I’ll take a snapshot before doing so. Thanks!

        1 Reply Last reply Reply Quote 0
        • Avaryan
          Avaryan last edited by Avaryan

          From what I’ve seen, when you import you can specify the OU path. Column L on my export.

          Use PowerShell to get the current OU’s.
          Something like:

          Get-ADComputer -Identity (Get-WmiObject Win32_ComputerSystem).Name | Select DistinguishedName -ExpandProperty DistinguishedName
          

          It’ll return:

          Example: CN=SaraDavisDesktop,CN=Europe,CN=Users,DC=corp,DC=contoso,DC=com
          

          You could export that to a CSV file. Format. Sort by hostname. Copy/Paste into your import file. Then import it.

          Might work. All theoretical.

          1 Reply Last reply Reply Quote 0
          • george1421
            george1421 Moderator @george1421 last edited by

            @george1421 Now to the sql dump file.

            This is the business end of the dump file.

            LOCK TABLES `hostname_fixup` WRITE;
            /*!40000 ALTER TABLE `hostname_fixup` DISABLE KEYS */;
            INSERT INTO `hostname_fixup` VALUES (1,'b8ca3ace1d1a',NULL),(4,'joebob',NULL),(3,'0800275f0038',NULL),(5,'tomcat',NULL);
            /*!40000 ALTER TABLE `hostname_fixup` ENABLE KEYS */;
            UNLOCK TABLES;
            /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
            

            The key in this the data line.

            INSERT INTO `hostname_fixup` VALUES (1,'b8ca3ace1d1a',NULL),(4,'joebob',NULL),(3,'0800275f0038',NULL),(5,'tomcat',NULL);
            

            the VALUES is the data from the table we exported.

            How I would go about this is to use notepad++ to clean up the data a bit and then import into excel. Match up the new and old names. Then export back to a text file and finally regroup into this data structure. You can change the format a bit to support the export from excel.

            LOCK TABLES `hostname_fixup` WRITE;
            /*!40000 ALTER TABLE `hostname_fixup` DISABLE KEYS */;
            INSERT INTO `hostname_fixup` VALUES 
            (1,'b8ca3ace1d1a',NULL),
            (4,'joebob',NULL),
            (3,'0800275f0038',NULL),
            (5,'tomcat',NULL);
            /*!40000 ALTER TABLE `hostname_fixup` ENABLE KEYS */;
            UNLOCK TABLES;
            /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
            
            

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

            1 Reply Last reply Reply Quote 0
            • george1421
              george1421 Moderator @george1421 last edited by george1421

              @george1421 Here is a rough outline of what needs to be done on the database side. Understand you do this at your own risk. I’m only suggesting one way to go about it.

              This concept uses a temporary table to hold both the old name and new names. Then we will export the hostid and existing host name to this temp table. This will build the structure of what we need. The mysqldump command will export the temp table with all of the data into a text file. You will have to tweak this file to insert the new names into the dump file. Next we will import that dump file back into mysql and then finally run an update command to replace the existing host name with the updated host name.

              mysql -u root

              USE fog;
              
              CREATE TABLE hostname_fixup (
                  hostID int,
                  hostName varchar(16),
                  newhostName varchar(16)
              );
              
              INSERT INTO hostname_fixup (hostID,hostName)
                SELECT hostID,hostName FROM hosts;
              
              EXIT;
              

              Export the fixup table
              mysqldump -u root fog hostname_fixup > hname_fixup.sql

              fixup the new host names in the dump file

              remove any windows nonsense with dos2unix command

              Import the database back into the fog server
              mysql -u root fog < hname_fixup.sql

              Login to mysql
              mysql -u root

              USE fog;
              
              UPDATE hosts
                     JOIN hostname_fixup
                     ON hosts.hostID = hostname_fixup.hostID
              SET    hosts.hostName = hostname_fixup.newhostName;
              
              DROP TABLE hostname_fixup;
              

              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

              george1421 1 Reply Last reply Reply Quote 0
              • Wayne Workman
                Wayne Workman last edited by

                I can assist with a script to do this - if we think it’s valuable. But I don’t think it’s really valuable to the community - what is wanted here is an edge case.

                @Joe-Schmitt I know. I just gave the way that anyone could do without scripting.

                Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!
                Daily Clean Installation Results:
                https://fogtesting.fogproject.us/
                FOG Reporting:
                https://fog-external-reporting-results.fogproject.us/

                1 Reply Last reply Reply Quote 0
                • george1421
                  george1421 Moderator @Joe Schmitt last edited by george1421

                  @Joe-Schmitt I agree that modifying the database directly is probably the best solution. But my question was around the mechanics of the fog client. The host rename function doesn’t touch/deal with AD does it? Its only a host rename??

                  Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                  george1421 1 Reply Last reply Reply Quote 0
                  • J
                    Joe Schmitt Senior Developer last edited by Joe Schmitt

                    @george1421 the problem is likely that he is deleting hosts and then importing them (I’m not sure if a CSV export stores this information). This is why I advised directly modifying the SQL database.

                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                    george1421 1 Reply Last reply Reply Quote 0
                    • george1421
                      george1421 Moderator @anthony.delarosa last edited by george1421

                      @anthony.delarosa said in Hostname Change on 700+ Workstations:

                      @Tom-Elliott by the way, any snap-in that would detect what OU the computer is in and be able to put it back into that same OU after import?

                      We will have to ask @Joe-Schmitt for confirmation, but a system rename shouldn’t remove the host from AD to rename it. It should just rename it and leave it where the system was in AD/OU. I can understand (re)connecting the target computer to AD may change its OU.

                      You could also do this with a VBScript or powershell script to rename the system. I’ve done this before with vbscript.

                      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

                      1 Reply Last reply Reply Quote 0
                      • Tom Elliott
                        Tom Elliott @anthony.delarosa last edited by

                        @anthony.delarosa I’m sure it could be done, but I don’t think anyone has set one up yet.

                        That said, you can use the FOG Client to join a host to a domain, including the OU.

                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                        1 Reply Last reply Reply Quote 0
                        • A
                          anthony.delarosa @Tom Elliott last edited by

                          @Tom-Elliott by the way, any snap-in that would detect what OU the computer is in and be able to put it back into that same OU after import? it’s a lot to ask but why not lol

                          Tom Elliott george1421 2 Replies Last reply Reply Quote 0
                          • A
                            anthony.delarosa @Tom Elliott last edited by

                            @Tom-Elliott that’s why you’re the creator and i’m just some guy breaking stuff lol ^_^ thanks Tom! with this I’ll be able to complete it by assigning them to a group

                            1 Reply Last reply Reply Quote 0
                            • Tom Elliott
                              Tom Elliott last edited by

                              @anthony.delarosa said in Hostname Change on 700+ Workstations:

                              2017-04-20 2:32 PM Middleware::Response Invalid security token

                              2017-04-20 2:32 PM Middleware::Response Invalid security token

                              Please go to the hosts you reimported to edit, and click the “Reset encryption data” button for them.

                              Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                              Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                              Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                              A 2 Replies Last reply Reply Quote 1
                              • A
                                anthony.delarosa last edited by

                                this is what the Hostname Changer shows:


                                --------------------------------HostnameChanger-------------------------------

                                2017-04-20 2:41 PM Client-Info Client Version: 0.11.9
                                2017-04-20 2:41 PM Client-Info Client OS: Windows
                                2017-04-20 2:41 PM Client-Info Server Version: 1.3.4
                                2017-04-20 2:41 PM Middleware::Response ERROR: Unable to get subsection
                                2017-04-20 2:41 PM Middleware::Response ERROR: Object reference not set to an instance of an object.

                                1 Reply Last reply Reply Quote 0
                                • A
                                  anthony.delarosa @Tom Elliott last edited by

                                  @Tom-Elliott hey Tom, thanks for that! it worked but after the import the PC (test PC) won’t change it’s hostname automatically. I mean FOG shows the new given name: van-wsz440-147 but the computer Windows 8.1 still has the old name vanprodz440-147 and it’s not rebooting automatically.

                                  FOG log file shows:


                                  --------------------------------Authentication--------------------------------

                                  2017-04-20 2:30 PM Client-Info Version: 0.11.9
                                  2017-04-20 2:30 PM Client-Info OS: Windows
                                  2017-04-20 2:30 PM Middleware::Authentication Waiting for authentication timeout to pass
                                  2017-04-20 2:32 PM Middleware::Communication Download: http://192.168.170.128/fog/management/other/ssl/srvpublic.crt
                                  2017-04-20 2:32 PM Data::RSA FOG Server CA cert found
                                  2017-04-20 2:32 PM Middleware::Authentication Cert OK
                                  2017-04-20 2:32 PM Middleware::Communication POST URL: http://192.168.170.128/fog/management/index.php?sub=requestClientInfo&authorize&newService
                                  2017-04-20 2:32 PM Middleware::Response Invalid security token

                                  1 Reply Last reply Reply Quote 0
                                  • Tom Elliott
                                    Tom Elliott @anthony.delarosa last edited by

                                    @anthony.delarosa Only remove the hosts you need to change from FOG.

                                    Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                    Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                    Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                    A 1 Reply Last reply Reply Quote 0
                                    • A
                                      anthony.delarosa @Tom Elliott last edited by

                                      @Tom-Elliott ah ok, so i export, make the changes to the 10x (example) hosts, remove all the other ones and re-import that file with 10x hosts? k let me try

                                      Tom Elliott 1 Reply Last reply Reply Quote 0
                                      • Tom Elliott
                                        Tom Elliott last edited by

                                        Right.

                                        You’re exporting to chagne the names.

                                        Then you remove all the hosts are you changing. Reimport.

                                        Essentially what you’re importing is failing because it already exists.

                                        Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                        A 1 Reply Last reply Reply Quote 1
                                        • A
                                          anthony.delarosa @Tom Elliott last edited by

                                          @Tom-Elliott hey Tom, remove them? sorry I wasn’t aware of this, I need to go in there and delete all the hosts and then import it again? All I did was export, modify and import the hosts and I keep getting this Row#0 error

                                          1 Reply Last reply Reply Quote 0
                                          • Tom Elliott
                                            Tom Elliott @anthony.delarosa last edited by

                                            @anthony.delarosa Did you remove all the hosts first?

                                            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

                                            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

                                            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

                                            A 1 Reply Last reply Reply Quote 1
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post

                                            59
                                            Online

                                            10.4k
                                            Users

                                            16.4k
                                            Topics

                                            150.7k
                                            Posts

                                            Copyright © 2012-2023 FOG Project