4 Replies Latest reply on Jan 23, 2012 7:43 AM by Rohit Nayyar

    To get Bios serialnumber of all servers on estate

      I have tried the below script but whilst the command "wmic bios get serialnumber" produces the correct information when run on an individual server when I try to run it in a script it sya it cannot find the file specified.

      My script is=

       

       

      # variables
      SERVER_LIST=$1
      FILE_SERVER="ppem106"
      OUTPUT_FILE="//${FILE_SERVER}/Temp/Bios.csv"

      # zero output file
      > ${OUTPUT_FILE}

      # loop through the list of servers
      for SERVER in ${SERVER_LIST}
      do
      # check if accessible
      agentinfo ${SERVER}

       

      if [ $? -eq 0 ]; then
        # get BIOS_VERSION
        BIOS_VERSION=$(nexec -l ${SERVER} wmic bios get serialnumber |grep -v serialnumber )
       
        # output hostname
        echo -n "${SERVER},${BIOS_VERSION}," >> ${OUTPUT_FILE}
          
      else
        echo "Agent Down: ${SERVER}"

       

      Can anyone see where I am going wrong?
      fi
      done

      # convert the output file to DOS format
      sed "s/$/`echo -e \\\r`/" ${OUTPUT_FILE} > ${OUTPUT_FILE}.tmp
      mv ${OUTPUT_FILE}.tmp ${OUTPUT_FILE}