General Question - downloading inventory Automated



  • This is more of a general question, but I am trying to see if anyone would know a way to download the inventory as CSV. I am trying to automate this and was thinking powershell

    $username = "user"
    $password = "pass"
     
    $ie = New-Object -com InternetExplorer.Application
    $ie.visible=$true
    $ie.navigate("url.lsps.org")
    while($ie.ReadyState -ne 4) {start-sleep -m 100}
    $ie.document.getElementById("username").value= "$username"
    $ie.document.getElementById("password").value = "$password"
    Start-Sleep -m 100
    $ie.document.getElementById("login-form-submit").click()
    Start-Sleep -s 4
    $ie.Navigate('http://fogserver.org/fog/management/?node=report&sub=inventory')
    Start-Sleep -s 4
    $ie.Navigate('http://fogserver.org/fog/management/export.php?type=csv')
    

    I can get this work in IE 11 but then I get a popup asking to save and I can’t figure out a way to stop this and my google-fu didn’t provide much luck. I can get all the elements and tags needed via this below snippet, but I am not sure how to input the data:

    $inv = Invoke-WebRequest 'fogserver.org' 
    $inv.ParsedHtml.getElementById("username")
    $inv.ParsedHtml.getElementById("password").value= "password"
    $inv.ParsedHtml.getElementById("login-form-submit").click()
    

    Any help is greatly appreciated.

    Thanks,





  • @Wayne-Workman said in General Question - downloading inventory Automated:

    Probably easier to just query the DB directly using the fogstorage MySQL account. Putting together a CSV is pretty easy. I don’t know how to do it in powershell, but in BASH it’s easy to do. I can help with that, but I didn’t want to go script that until you responded saying that would work for you.

    @Wayne-Workman thanks for offering a better solution I actually think that this would work better. If you could provide a bit of insight how to query the database I think it would work best.
    Thanks for your assistance.
    If you can post the bash version I will work on the powershell version and share it as well.



  • Probably easier to just query the DB directly using the fogstorage MySQL account. Putting together a CSV is pretty easy. I don’t know how to do it in powershell, but in BASH it’s easy to do. I can help with that, but I didn’t want to go script that until you responded saying that would work for you.


 

612
Online

5.4k
Users

12.6k
Topics

118.7k
Posts