Loading
Snow XML import

I am trying to import devices into snow using snow XML import. But the output that i get from the script shows only 1 device in the xml. 

 

Here is the template & script that i have:

 

Host;Domain;CompType;CompManufacturer;User;OS;SWManufacturer;SWName;Version COMP0001;AU;Notebook;HP;user1; User1;MS;MS Visio 2010;2010 

 

## Check for correct input parameters 

if($args.Count -ne 3) 

{ Write-Output "" "csv2snow.ps1" "" "Syntax:" ".\csv2snow.ps1 <path to input.csv> <output-path> <sitename>" "" "Example:" ".\csv2snow.ps1 D:\snowtemplate.csv D:\Device XML" "" 

return 

} 

else 

{ 

$report=$args[0] 

$outputdir=$args[1] 

$sitename=$args[2]

 

## Check that the input file exists, otherwise exit 

if (!(test-path($report))) { write-host "Input file not found.";return }

 

## Check that the output directory exists, otherwise create it if (test-path($outputdir)) { } else { mkdir $outputdir > $ }

 

## Import the report write-host (get-date) "Importing file.." $myinput = import-csv $report -Delimiter ";" $totalrows = $myinput.Length write-host "$totalrows rows found" $current = 0 $currhost = $myinput[$current].host write-host $currhost $prods = @() $now = get-date

 

## Go through all rows of the CSV while ($current -lt $totalrows) { $h = $myinput[$current].host if($h -ne $currhost) { #process the old host, then start with the new data write-host (get-date) "Processing host $currhost"

 

## Start writing the SnowXML for the host 

$output_file = $outputdir + "\" + $currhost +'.xml'

$XmlWriter = New-Object System.XMl.XmlTextWriter($output_file,$) 

$xmlWriter.Formatting = [System.Xml.Formatting]::Indented 

$xmlWriter.WriteStartDocument()

$lastupdate = $now.ToString("yyyy-MM-ddThh:mm:ss")

 

$xmlWriter.WriteStartElement("client") 

$xmlWriter.WriteElementString('isdmisupported',"false") 

$xmlWriter.WriteElementString('isapmsupported',"false") 

$xmlWriter.WriteElementString('isplugandplay',"false") 

$xmlWriter.WriteElementString('primarybustype',"false") 

$xmlWriter.WriteElementString('secondarybustype',"false") 

$xmlWriter.WriteElementString('hasusb',"false") 

$xmlWriter.WriteElementString('biosreleasedate','1900-01-01T01:00:00') 

$xmlWriter.WriteElementString('biosmanufacturer','(n/a)') 

$xmlWriter.WriteElementString('biosserialnumber','(n/a)') 

$xmlWriter.WriteElementString('biosversion','(n/a)') 

$xmlWriter.WriteElementString('company',"false") 

$xmlWriter.WriteElementString('dmiversion',"false") 

$xmlWriter.WriteElementString('hasflashbios',"false") 

$xmlWriter.WriteElementString('hostname',$currhost) 

$xmlWriter.WriteElementString('isportable','false') 

$xmlWriter.WriteElementString('lastupdate',$lastupdate) 

$xmlWriter.WriteElementString('numberofprocessors','1') 

$xmlWriter.WriteElementString('manufacturer','(n/a)') 

$xmlWriter.WriteElementString('model','(n/a)') 

$xmlWriter.WriteElementString('username','(n/a)') 

$xmlWriter.WriteElementString('installdate',"1900-01-01T01:00:00") 

$xmlWriter.WriteElementString('sitename',$sitename) 

$xmlWriter.WriteElementString('clientidentifier',$currhost) 

$xmlWriter.WriteElementString('clienttype',0) 

$xmlWriter.WriteElementString('isvdi',"false") $xmlWriter.WriteStartElement("memory") 

$xmlWriter.WriteElementString('freeslots',"0") 

$xmlWriter.WriteElementString('freeswap',"0") 

$xmlWriter.WriteElementString('maxphysical',"0") 

$xmlWriter.WriteElementString('totalslots',"0") 

$xmlWriter.WriteElementString('totalphysical',"0") 

$xmlWriter.WriteElementString('totalvirtual',"0") 

$xmlWriter.WriteElementString('freevirtual',"0") 

$xmlWriter.WriteElementString('freephysical',"0") 

$xmlWriter.WriteElementString('totalswap',"0") 

$xmlWriter.WriteEndElement()

 

## Process the software for the host 

foreach ($prod in $prods) { $xmlWriter.WriteStartElement("application") 

$xmlWriter.WriteElementString('binarytype',"0") 

$xmlWriter.WriteElementString('format',"0") 

$xmlWriter.WriteElementString('installdate',"1900-01-01T12:00:00") 

$xmlWriter.WriteElementString('name',$prod.SWName) 

$xmlWriter.WriteElementString('islocal',"true") 

$xmlWriter.WriteElementString('ismsi',"true") 

$xmlWriter.WriteElementString('isshortcut',"false") 

$xmlWriter.WriteElementString('processortype',"0") 

$xmlWriter.WriteElementString('uninstallstring',"0") 

$xmlWriter.WriteElementString('filename',"(n/a)") 

$xmlWriter.WriteElementString('filepath',"(n/a)") 

$xmlWriter.WriteElementString('filedatetime',"1900-01-01T12:00:00") 

$xmlWriter.WriteElementString('filesize',0) 

$xmlWriter.WriteElementString('version',"SNOWXML-" + $prod.SWVersion) 

$xmlWriter.WriteElementString('manufacturer',"(n/a)") 

$xmlWriter.WriteElementString('language',"Language Neutral") 

$xmlWriter.WriteElementString('fullcappeakdate',"1900-01-01T12:00:00") 

$xmlWriter.WriteElementString('isrecognized',"1") 

$xmlWriter.WriteElementString('coresublimit',"0") 

$xmlWriter.WriteElementString('issubcapacity',"false") 

$xmlWriter.WriteElementString('subcappeakdate',"1900-01-01T12:00:00") 

$xmlWriter.WriteElementString('pvusubcap',"0") 

$xmlWriter.WriteElementString('ispvu',"false") 

$xmlWriter.WriteElementString('coresubcap',"0") 

$xmlWriter.WriteElementString('pvusublimit',"0") 

$xmlWriter.WriteEndElement() }

$xmlWriter.WriteStartElement("networkadapter") 

$xmlWriter.WriteElementString('dnsserver',"0") 

$xmlWriter.WriteElementString('macaddress',"0") 

$xmlWriter.WriteElementString('productname',"0")


  • Detlev Eufinger (Flexera Software)

    Hi  Dheemant all Looks like fine... in your template you have only one line for one Computer.... so the Output is als only one Please use for each Computer and Software one line COMP0001;AU;Notebook;HP;user1;;MS;MS Visio 2010;2010 COMP0001;AU;Notebook;HP;user1;;MS;MS Excel 2010;2010 COMP0002;AU;Notebook;HP;user1;;MS;MS Visio 2010;2010
  • Gigi Carlino (Flexera Software)

    can you attach the cvs file that you are using?
    • Community Manager (Flexera Software)

      Hi Gigi, We are working with the customer and helping them with the XML imports. Kind regards, Iwan van den Hoek
  • I am interested in something similar. The powershell script appears to be cut at the end - where can the csv2snow.ps1 be downloaded from fully?

Related  Product Forums


                     → Flexera One



                      → Snow Atlas



                      → FlexNet Manager



                      → Snow License Manager



                       → App Broker


       Need help finding an answer?


        Ask a Question →


Loading
Snow XML import