Grab Windows hostname during imaging??



  • Server
    • FOG Version: 1.2
    • OS: Ubuntu 14.04
    Client
    • Service Version: Standard 1.2 Fog service
    • OS: Windows
    Description

    This might seem like an odd question, but I want to grab the hostname of the computer from the FOG database before the computers hostname actually get’s changed on the Windows client side (at this point the FOG service hasn’t changed the Windows hostname yet). So in other words, once the computer has been imaged and the initial scripts have started, from the Windows client side, I want to log the hostname somehow if something specific happens. For example, I have a way to detect if the video driver has been successfully updated. If the driver has not been updated during my driver install process, it would be nice to take that hostname and LOG it or email myself using scripts. I started to look a little bit into it, and the solution was leading me down a path of connecting to the mysql database and running a command using putty against the hosts table to get the hostname. But that seemed extremely messy, so before I go any further, does anyone know of a way to do this using the existing FOG service or something from the Windows client side? Any custom command I can run from the Windows FOG client side to grab data like that? I hope that makes sense.

    Dustin Olson


  • Moderator

    @dustindizzle11 Thank you for sharing what you’ve learned> I’m sure it will help others as they find this thread in the future. Well done!!



  • @george1421 Thanks so much for your response. Just to share with anyone else who might use it, I just created a Powershell script that gets the hostname and emails me an alert about the system. Script below if you want it…(I am calling the script if certain criteria are not met (like missing drivers or something)…

    $test=Test-Connection $env:COMPUTERNAME -count 1 | select Ipv4Address
    $IP=$test.IPV4Address.IPAddressToString
    $MAC=(gwmi -Class Win32_NetworkAdapterConfiguration | where { $_.IpAddress -eq $IP }).MACAddress
    
    
    $Hostname=Invoke-WebRequest http://192.168.64.14/fog/service/hostname.php?mac=$MAC
    $Hostname=$Hostname -split("\n")
    $Hostname=$Hostname[0]
    $Hostname=$Hostname.Replace("#!ok=", "")
    $Hostname=$Hostname.Trim()
    
    Send-MailMessage -To "YOURTOEMAIL" -From "FOG_WARNING@FOGALERTS.NET" -Subject "$Hostname Alert" -SmtpServer "YOUR SMTP SERVER" -Body "$Hostname had a problem... You need to fix this!!!!!"
    

    Mod edited to use codebox.


  • Moderator

    I can’t say this idea will work for 1.2.0 but there IS a way to get some info from FOG. Its not official, unsupported, and may not work in the next release of FOG…

    From some functioning script on your target system… If you can call this script url on the FOG server.

    http://<fog_server_ip>/fog/service/hostname.php?mac=<mac_address_of_target_computer>
    

    This script will respond with:

    #!ok=<target_hostname> #AD= #ADDom= #ADOU= #ADUser= #ADPass=
    

    You can then just parse out the fields you are interested in.

    Understand this mysterious script will be running on the target computer and can use any scripting methods supported on the target system.


  • Moderator

    @dustindizzle11 If you were using FOG 1.3.x there is postinstall scripts that could be used.

    I realize that since you are still using FOG 1.2.0 the following isn't possible for you. But I wanted to show you what "could" be done.

    In my case, I don’t use the fog client to rename the system name. Instead I have a postinstall script collect the details from fog and then use a sed script to update the unattend.xml file with the system name.

    You could use a similar concept to “patch” a vbscript with the system host name that fog will set with a post install script.

    https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script/7


Log in to reply
 

332
Online

38727
Users

10554
Topics

99920
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.