locked
Powershell working on xml RRS feed

  • Question

  • Hi,

    I'm starting to work with xml in powershell and I have stuck with it. My case: I have to inventory workstation/laptops in env that I have windows xp/windows 7 without SP1. I found and tested script in vbs but i got output in xml -  example :

    <bios version="LENOVO - 2510" smbiosversion="GLET97WW (2.51 )" smbiosmajorversion="2" smbbiosminorversion="7">
      <bioscharacteristics id="7" name="PCI is supported" />
      <bioscharacteristics id="9" name="Plug and Play is supported" />
      <bioscharacteristics id="11" name="BIOS is Upgradable (Flash)" />
      <bioscharacteristics id="12" name="BIOS shadowing is allowed" />
      <bioscharacteristics id="15" name="Boot from CD is supported" />
      <bioscharacteristics id="16" name="Selectable Boot is supported" />
      <bioscharacteristics id="32" name="ACPI supported" />
      <bioscharacteristics id="33" name="USB Legacy is supported" />
      <bioscharacteristics id="40" name="Unknown (Undocumented)" />
      <bioscharacteristics id="42" name="Unknown (Undocumented)" />
      <bioscharacteristics id="43" name="Unknown (Undocumented)" />
     </bios>
     <osconfiguration osname="Microsoft Windows 10 Pro" computerrole="Standalone Workstation" domainname="WORKGROUP" domaintype="workgroup" windowslocation="C:\WINDOWS" oslanguage="Polish" installdate="2019-01-19 23:47:48" />
     <lastuser name="" />
     <windowscomponents>
      <component name="Internet Explorer (from Start Menu and Desktop)" class="0800" classname="" level="1" />
      <component name="Windows Media Player (from Start Menu and Desktop)" class="2200" classname="" level="1" />
     </windowscomponents>
     <installedapplications>
      <msiapplication productname=". ." vendor="Intel" version="7.1" installdate="20170321" />
      <msiapplication productname=". . ." vendor="Intel" version="2.7.2.4" installdate="20170321" />

    To create reports and diagrams, I have to export it to csv. will be good if I use company sheet for it ( the columns is already predefined). Example:

    Type of device Name Manufacturer Model Memory Proccessor BIOS

    I try to work with get-content cmdlet and select-xml but I do not have idea for next step.

    Can someone guide me how to get final summary based on above example.

    Tuesday, April 16, 2019 11:11 AM

All replies

  • If that were valid xml, this would convert it to an object.  There's no top level node, and the installedapplications node isn't closed.

    $xml = (select-xml / file.xml).node

    • Edited by JS2010 Tuesday, April 16, 2019 3:18 PM
    Tuesday, April 16, 2019 12:15 PM
  • <?xml version="1.0" encoding="ISO-8859-1" ?>
    <?xml-stylesheet type="text/xsl" href="serverhtml.xsl"?>
    <computer>

    <installedapplications>
      <msiapplication productname=". ." vendor="Intel" version="7.1" installdate="20170321" />
      <msiapplication productname=". . ." vendor="Intel" version="2.7.2.4" installdate="20170321" />
      <msiapplication productname="Adobe Acrobat Reader DC - Polish" vendor="Adobe Systems Incorporated" version="19.010.20099" installdate="20190411" />
      <msiapplication productname="Adobe AIR" vendor="Adobe Systems Incorporated" version="29.0.0.112" installdate="20180318" />
      <msiapplication productname="Adobe Refresh Manager" vendor="Adobe Systems Incorporated" version="1.8.0" installdate="20190214" />
      <msiapplication productname="Apple Application Support (32-bit)" vendor="Apple Inc." version="6.6" installdate="20180829" />
      <msiapplication productname="Apple Application Support (64-bit)" vendor="Apple Inc." version="6.6" installdate="20180829" />
      <msiapplication productname="Apple Mobile Device Support" vendor="Apple Inc." version="11.4.1.46" installdate="20180829" />
      <msiapplication productname="Apple Software Update" vendor="Apple Inc." version="2.6.0.1" installdate="20180330" />
      <msiapplication productname="Bonjour" vendor="Apple Inc." version="3.1.0.1" installdate="20160928"/><regapplication productname="Windows Driver Package - Synaptics (SmbDrv) System  (10/22/2014 18.0.7.98)" version="10/22/2014 18.0.7.98" />
      <regapplication productname="Windows Driver Package - Synaptics (SynTP) Mouse  (10/22/2014 18.0.7.98)" version="10/22/2014 18.0.7.98" />
     </installedapplications>

    </computer>


    Tuesday, April 16, 2019 12:43 PM
  • Tuesday, April 16, 2019 2:53 PM