Jump to content

Recommended Posts

Posted

I have a list of staff members and their staff codes. I have managed to export it as an XML file in SIMS and used the following command to import it as an object in Powershell:

 

[xml]$Staff = Get-Content "staffcodes.xml"

 

Unfortunately when I run the following:

 

$Staff.SuperStarReport.Record | Out-Gridview

 

It is only showing the first two nodes of Forename and Surname. The third node Initials, which contains the staff code, isn't being shown because the first member of staff doesn't have that data item as they lack a staff code. I can fix this by adding in their record but this has to be done manually. Is there any way of forcing Get-Content to pick up a node even if the first record for that node is blank?

 

I could sort it so the first staff member fills all three nodes but this isn't suitable looking forwards and handling bigger sets of data in the future.

Posted

If you actually list what you want to pull out it'll show them even if blank

 

e.g. | ft FirstName, Surname, Initials -AutoSize

 

etcetc

 

Steve

  • Thanks 1
Posted (edited)
Ahh I see it's a display problem. That works, sort of! If I try to convert it into a CSV file it still only shows the first two columns and with Format-Table it mangles the data into oblivion. And Out-Gridview just says no to wrong data type. Edited by CAM
Posted

You got an example of what you're using code wise and what you want it to do? where's the CSV come into it? If you want a CSV you can do that from SIMs couldn't you? :o

 

Steve

Posted (edited)

Not sure what you mean with the issue though, that'll scan through and list any xml whether it's got a gap or not though

 

Example:

 

XMLPowershell.png

 

Or isn't that what you need?

 

-Edit - Or if you really want it view a gridview just select the properties prior to the pipe:

 

XMLPowershell2.png

 

Steve

Edited by Steve21

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...