Combine Columns From Separate Arrays Into One Formatted Table

What I'm trying to do is make two WMI queries with 2 different classes for a list of machines and then patch the columns together into one single array that is formatted as a table with columns and rows. I seem to keep banging my head against the wall and
I can't help but feel that the answer is simple. I can certainly create an array that contains all 3 columns (such as in the commented out part) but no matter which angle I go at it, it always seems to end up as all the data in one single row in each column
rather than a nicely formatted table. I've even tried constructing separate custom objects and adding the different objects to the array but that's obviously not working. Below is the code of the last thing I tried. I need someone to bash it to death and tell
me the (most likely obvious) thing that I'm doing wrong. Thanks!
$failedos = @()
$failedcs = @()
$ccs = get-adcomputer -property operatingsystem -filter {name -like "*-CC*"} | select name | sort name
$cs = foreach ($cc in $ccs){$cc.name | % {if ($c=get-wmiobject -computername $cc.name -class win32_computersystem -ErrorAction SilentlyContinue){$c | select @{Name="Name";Expression={$_.Name}}, @{Name="Model";Expression={$_.Model}}} else {$failedcs += "$_"}}}
$os = foreach ($cc in $ccs){$cc.name | % {if ($o=get-wmiobject -computername $cc.name -class win32_operatingsystem -ErrorAction SilentlyContinue){$o | select @{Name="OperatingSystem";Expression={$_.caption}}} else {$failedos += "$_"}}}
#[array]$osprops = @{'Name'=$cs.Name;'Model'=$cs.Model;'OperatingSystem'=$os.OperatingSystem}
$result = @()
Foreach ($Line in $cs) {
$MyCustomObject = New-Object -TypeName PSObject
Add-Member -InputObject $MyCustomObject -MemberType NoteProperty -Name "Name" -Value $Line.name -Force
Add-Member -InputObject $MyCustomObject -MemberType NoteProperty -Name "Model" -Value $Line.Model -Force
$result += $MyCustomObject
foreach ($Line2 in $os) {
$MyCustomObject2 = New-Object -TypeName PSObject
Add-Member -InputObject $MyCustomObject2 -MemberType NoteProperty -Name "OperatingSystem" -Value $Line2.OperatingSystem -Force
$result += $MyCustomObject2

Any help?
$ccs = get-adcomputer -property operatingsystem -filter {name -like "*-CC*"} |
select -ExpandProperty name | sort
$Result =
Foreach ($CC in $CCs)
$Object =
New-Object PSObject -Property @{ Name = $CC
Model = 'Failed'
OperatingSystem = 'Failed'
Try {
$Object.Model =
get-wmiobject -computername $CC -class win32_computersystem -ErrorAction Stop |
select -ExpandProperty Model
$Object.OperatingSystem =
get-wmiobject -computername $CC -class win32_operatingsystem -ErrorAction Stop |
select -ExpandProperty Caption
Catch{}
Finally { $Object }
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

Similar Messages

  • Combine CSV columns from multiple sources into one

    Hi, 
    I am trying to import column from one CSV file and output it into additional columns on a Get-MailboxStatistics | Export-CSV command. The issue with the script I have created is that when use an Expression to create the new column it outputs all of the items
    in the column from the import CSV into one row. See script below, I have highlighted the expressions that are not working.
    Any assistance would be appreciated. 
    [Array]$Global:NotesMailSizeMaster = (Import-Csv c:\usermigration.csv).MailSizeMaster
    [Array]$Global:NotesMailSizeRefresh = (Import-Csv c:\usermigration.csv).MailSizeRefresh
    [Array]$Global:UserAlias = (Import-Csv c:\usermigration.csv).Alias
    if (!(Get-PSSnapin |
    Where-Object { $_.name -eq "Microsoft.Exchange.Management.PowerShell.Admin" }))
    ADD-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
    $Output = ForEach ($Alias in $UserAlias)
    { Get-MailboxStatistics $Alias | select-object DisplayName, ServerName, StorageGroupName, Database, @{ Name = "TotalItemSize"; expression = { $_.TotalItemSize.Value.ToMB() } },
    @{ Name = "NotesMailSize(PreRefresh)"; expression = { $NotesMailSizeMaster } }, @{
    Name = "NotesMailSize(PostRefresh)"; expression = { $NotesMailSizeRefresh }
    $filename = (Get-Date).ToString("yyyyMMdd")
    $Output | export-csv -Path c:\"$filename-mailboxstats.csv" -NoTypeInformation

    There's a lot wrong with this script:
    1.  You're importing the same file 3x; you should import one and reference the things you need out of it.
    2.  If the CSV has more than one row in it, your .notation you're using to access the MailSizeMaster, MailSizeRefresh, and Alias properties is used incorrectly.  If you are trying to reference each of those properties from an array of different entries,
    the proper way would be:
    $Import = @(Import-Csv C:\usermigration.csv)
    $MailSizeMaster = $Import | Select-Object MailSizeMaster
    OR
    $MailSizeMaster = $Import | Select-Object -Expand MailSizeMaster
    ...the "OR" is not PowerShell. 
    3.  I don't know if you can concatenate different objects with the select-object cmdlet like you are.  However, what you could do is create a custom object to load the values into and then output that object:
    $filename = (Get-Date).ToString("yyyyMMdd")
    foreach ($item in $Import) {
    $MS = Get-MailboxStatistics $item.Alias
    New-Object PSObject -Property @{
    'DisplayName' = $MS.DisplayName
    'ServerName' = $MS.ServerName
    'StorageGroupName' = $MS.StorageGroup
    'Database' = $MS.Database
    'NotesMailSizePre' = $item.MailSizeMaster
    'NotesMailSizePost' = $item.MailSizeRefresh
    } | Select-Object DisplayName,ServerName,StorageGroupName,Database,NotesMailSizePre,NotesMailSizePost | Export-Csv -NoTypeInformation "C:\$($filename)-mailboxstats.csv"

  • HT4436 Merging Tracks from separate computers into one Cloud account...

    My iTunes for my MacBook and PC are the same account, but currently have different tracks.  Will I be able to merge all these into one account, and have equal access to them?

    iCloud is a separate service from iTunes, creating an iCloud account will not resolve your iTunes issues. You may be interested in iTunes Match.

  • How to combine data from two rows into one row

    I have the following sets of data. I want to find all the duplicate sets of field values. in the data below there is only one duplicate set: brenda, analyst, green.
    DocID and Doc Seq combine to form the set key. FieldID I believe are consistent in that 1 is always name, 2 is job, 3 is favorite color etc. but there are up to 20 field IDs.
    To tell you the truth, my client is a bit sketchy about the data and the values. I would like collapse the sets by getting all the field values into a single row. They could be in the same column, or in their own columns. This way I can then look for whatever
    dups my customer seems to think that he has.
    the first image is what i want (either in same column or in different columns. but they have to be in the order of the FieldID), the second is what i have. THANKS

    CREATE TABLE #t (
    c1 INT NOT NULL PRIMARY KEY,
    c2 VARCHAR(50) NOT NULL
    GO
    INSERT INTO #t(c1, c2) VALUES(1, 'P1,P2,P3')
    INSERT INTO #t(c1, c2) VALUES(2, 'P2,P3')
    GO
    -- Generate set of numbers
    -- Idea from Itzik Ben-Gan
    ;WITH
    L0 AS (SELECT 1 AS n UNION ALL SELECT 1),
    L1 AS (SELECT 1 AS n FROM L0 AS a, L0 AS b),
    L2 AS (SELECT 1 AS n FROM L1 AS a, L1 AS b),
    L3 AS (SELECT 1 AS n FROM L2 AS a, L2 AS b),
    L4 AS (SELECT 1 AS n FROM L3 AS a, L3 AS b),
    Numbers AS (SELECT ROW_NUMBER() OVER(ORDER BY (SELECT 1)) AS Number FROM L4)
    SELECT
    t.c1,
    t.c2,
    SUBSTRING(',' + t.c2 + ',', Number + 1, CHARINDEX(',', ',' + t.c2 + ',', 
    Number + 1) - Number - 1) AS Item,
    ROW_NUMBER() OVER(PARTITION BY t.c1 ORDER BY n.Number) AS rn
    FROM
    #t AS t, Numbers AS n
    WHERE
    n.Number <= LEN(t.c2)
    AND SUBSTRING(',' + t.c2 + ',', n.Number, 1) = ','
    ORDER BY
    t.c1, rn
    GO
    DROP TABLE #t
    GO
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • All values from associative array into one variable

    Hello! Please:
    I have, for example:
    DECLARE
      TYPE tb1 IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
      v4 tb1;
      variable1 myType; --varray of integers
    BEGIN
      v4(1)   := 34;
      v4(2)   := 46456;
      v4(100) := 54217:
      ...  --shortly -lot of values
    END;
    /How can I get all v4(x) values into variable1?
    something like:
    FOR i IN 1..v4.COUNT
    variable1 :=...don't know
    --to have this in the variable1: variable1:= myType(34, 46456, ..., 54217, ...);
    END LOOP;Thank You for answer!

    Is this you are looking for?
    create or replace type myType is varray(500) of number;
    DECLARE
    TYPE tb1 IS TABLE OF INTEGER INDEX BY PLS_INTEGER;
    v4 tb1;
    variable1 myType:=myType(); --varray of integers
    BEGIN
    v4(1) := 34;
    v4(2) := 46456;
    v4(3) := 54217;
    FOR i IN 1..v4.COUNT loop
    variable1.extend();
    variable1(i) := v4(i);
    END LOOP;
    FOR i IN 1..variable1.COUNT loop
    dbms_output.put_line(variable1(i));
    end loop;
    END;
    /

  • How Can I Combine Podcasts from Two Computers Into One ?

    I download podcasts on two computers - my home PC and my work/travel laptop. My IPod syncs to my home PC. What I would like to be able to do is transfer all the podcasts I have downloaded from my laptop to my home PC (as my internet speed at home isn't great), then sync it all to my IPod. Is this possible ?

    Well it works.....sometimes. It works OK with audio podcasts, but not with *.mov video podcasts. It DOES work with *.M4V video podcasts. I found this out by trying to add all the Tiki Bar TV files, and only the Boomerang episode transferred OK.
    The strange thing is this - while the *.MOV vpodcasts don't show up in the Podcast window in ITunes, they DO transfer over and show up in Library>Genre 'Podcasts'>. How can I force them to appear in the Podcasts window ?
    Cheers
    Blewyn

  • Combine Accounts from different Generations into a single Table Prompt

    We are on OBIEE 11.1.1.6.2 and using an ASO (11.1.2.1) cube as a datasource.
    I wish to make a drop down menu of only ten accounts in OBIEE. These ten accounts do not all belong in the same generation. The desired Accounts are from Gen6, Gen5 and Gen4. How do I make a single drop down list with these ten accounts when the members belong to different generations ? I have tried building this custom list of ten accounts via Selection Steps but it seems that I cannot cross different generations of the Account dimension.
    Any help would be appreciated.

    Thanks for the reply Christian. I literally tried at least 100 possible iterations of the Evaluate statement and none of them will compile in OBIEE. Before posting, I scoured the Internet for days hoping someone else has had this issue resolved. I had no luck. If you know of anyone that has actually been successful with the EVALUATE statement to make a list of dimension members from different generations, please post the exact code snippet so that I can leverage off of somone else's knowledge.
    I have tried dozens of possible iterations of: with no luck at all.
    EVALUATE('Intersect(%1.dimension.members,{[Account1], [Account2]})',"Account"."Gen1,Account")

  • How do I combine two arrays into one?

    I am trying to combine two byte arrays into one. What function do I use that will put in the information in the same order just combined?

    battler. wrote:
    Julien,
    Used LV for years.  Never knew that (concatenate inputs).  Wouldn't believe the lengths ive used to get around it.  Thanks
    Same here! I actually learned about it taking a sample test for the CLAD.
    Richard

  • How do you combine pages from separate PDFs?

    How do you combine pages from separate PDF files into one document?

    I use Adobe Acrobat for this.

  • Excel & ActiveX: Insert arbitrary columns from 2D array and create graph problems

    Hi there,
    I want to insert data from either a 1D or 2D array from LabView into Excel and create graphs.
    I used the information from the following example:
    http://www.ni.com/example/28934/en/
    and was able to create a new Excel file (I'm using Excel 2010), writing data from an 1D array to a column in excel by creating a while loop and using the first element of the array to write it to a specific cell. I use the counter of the loop to write to the next cell when the loop starts over and always delete the first value, which I write to the cell, from the array until it is empty.
    Now I also would like to write a 2D array - so the first column in Excel should be the first column from the array and so. Here I cannot use the loop counter directly as Excel only counts 1,2,... for the rows, but uses A,B,... to count columns. Also I do not know in advance how many columns my 2D array will contain, so creating a lookup table like (A means 1, B means 2,...) is not really an option (except there really is no other way). Is there a possibilty to convert numbers into letters or some way to 'explain' to the program that column 2 in the array means column B in Excel for example, or is there a way to insert new columns?
    I figured out how to add new Worksheets and as I also need to create a certain number of Worksheets and I know that on standard 3 sheets are present when creating the file, I use the 'add' methode to create every new worksheets before worksheet 3 - I could use the same methode to create new columns in Excel, but so far I didn't find a methode to do so. Or is there a way to enter the whole 2D array at once?
    Then I'd like to create a graph (in case of the 1D arrays a bar plot, when using 2D arrays a 3D plot) to view the data. I found this example:
    http://www.ni.com/newsletter/51339/en/
    -> as I do not have the toolkit I'd like to do it using ActiveX directly, so I tried to do things like shown under the headline 'DIY ActiveX/.NET'
    I tried to load the snippet to a new Excel file but got the error message 'microsoft.office.interop.excel.dll not found' and hence the code is not working. That confuses me a little as I would guess when this dll is not present I cannot access Excel from LabView at all, though my understanding of what I'm really doing so far is quiet limited. ;-)
    Also - as far as I understand from the snippet - when creating a new chart object I should be able the create methodes for it, however when I do a right click on the chart object of an ActiveX Worksheet symbol there are none listed.
    To explain my problems better I added a snippet showing my two problems: The inner of the two while loops shows how I import a 1D array. In the outer loop I seperate the columns. I know that currently this is not working as all data end up in column A of the Excel sheet - so I would need to convert the number of the outer counter to A, B,... or find a different solution.
    Moreover on the snippet I placed an ActiveX Worksheet Property with the Chart Object - as I can see the difference to the Chart Object in the example code from the last link above is the color. However I'm not sure what that means and how to change/ solve this.
    And just to make sure - I know this way the VI does not run as the Chart Object is placed completely wrong - I just did it, so it is included in the snippet.
    I'd be thankful for any suggestions,
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    ExcelAreaScan.png ‏60 KB

    Hello everyone and thanks for the answers.
    I only have the LabView Student Edition available here - is the toolkit included in it too. How can I check if it is installed/ available and in case it is installed - where can I find it?
    Today I had time to take a look at the example
    Create via ActiveX Labview a XY Scatter plot graph on an excel sheet
    It almost does what I want in terms of creating a graph. The only problem I could not fix, is that in this example a sheet is created where only the graph is present. i'd like to add the graph to a previously created worksheet. Today I tried get this working but it seems I stilll don't really understand what I'm doing, I'll post a snippet of my code as soon as I can access the PC with LabView on it again.
    I also took a look at the other example for inserting 2D attays - it seems to be what I need, I just had no time so far to test it, I'll post an update when I could test it.
    Thanks for the help so far!

  • How do I combine two user iPhoto files into one...keeps blocking the pics between users

    How do I combine two user iPhoto files into one...keeps blocking the pics between users on the same Mac?

    Put the library on an external hard drive that is formatted as shown in this screenshot:
    OT

  • How do I combine two or more pictures into one?

    How do I combine two or more pictures into one?

    I found out how to do what I wanted and I'm giving my steps in hopes that it might help someone else.  I wanted to put several photos from a file onto a new blank image.  This is what I did.
    1.  Create a blank page.    File/New/ Blank File.   Put in the size.  I used 8x10.
    2.  Bring the photo  you want to use into Elements as you always do. It will list along the top next to the blank sheet.
    3.  Choose SELECT (top of screen)/ Select All.
    4.  Choose Edit/Copy   or Command "C"
    5.  Click on the Blank File.   Chose Edit/Paste  or Command "V"
    6.  Click on Image/ Transform or Command "T".  There should be a dotted line around your pasted image.  You can then move and adjust the image to how you want it.  When finished, press the check-mark on lower right of photo.
    7.   Repeat this with all the photos you want on the new blank file.
    8.  You will see on lower right of Elements,  the background layer and as many layers as you have photos.  These layers need to be permanently placed on the background layer. Go to Layers and press Merge Visible.  This will merge all layers to the background.
    9.  Save as and you are done.

  • Copying Multiple Arrays into One Large Array

    I'm currently trying to copy multiple character arrays into one larger character array in a method that prints data gathered from a database. Here is my code:
    private static void printData(String[] data){
            try {
                int totalLengthOfAllStrings = 0;
                for(int i = 0; i < data.length; i++) {
                    data[i] += '\n';
                    totalLengthOfAllStrings += data.length();
    int runningLength = 0;
    char[] printArray = new char[totalLengthOfAllStrings];
    for(int j = 0; j < data.length; j++) {
    char[] tempArray = data[j].toCharArray();
    runningLength += tempArray.length;
    System.arraycopy(tempArray, 0, printArray, runningLength - 1, tempArray.length);
    DocFlavor df = DocFlavor.CHAR_ARRAY.TEXT_PLAIN;
    Doc printDoc = new SimpleDoc(printArray, df, null);
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    aset.add(new Copies(1));
    aset.add(MediaSize.NA.LETTER);
    aset.add(Sides.DUPLEX);
    PrintService[] services = PrintServiceLookup.lookupPrintServices(df, aset);
    if (services.length > 0) {
    DocPrintJob job = services[0].createPrintJob();
    try {
    job.print(printDoc, aset);
    System.out.println("Print successful!");
    catch (PrintException pe) {
    catch(Exception e) {
    e.printStackTrace();
    I keep getting an ArrayIndexOutOfBoundsException and for the life of me I can't figure out why.
    Can anyone help with this?
    Thanks!
    -Matt

    I think your problem lies with the second for loop:
    for(int j = 0; j < data.length; j++)  {
        char[] tempArray = data[j].toCharArray();
        runningLength += tempArray.length;
        System.arraycopy(tempArray, 0, printArray, runningLength - 1, tempArray.length);
    }If I am not wrong, you should swap the sequence of the runningLength and System.arraycopy statements, and also move the minus 1 from arraycopy statement to the runningLength statement. The result would look like this:
    for(int j = 0; j < data.length; j++)  {
        char[] tempArray = data[j].toCharArray();
        System.arraycopy(tempArray, 0, printArray, runningLength, tempArray.length);    // swapped and removed the -1
        runningLength += tempArray.length - 1;    // swapped and appended the -1
    }The main reason for these changes is because when j == data.length - 1, the value of runningLength would have already exceeded the size of printArray. Therefore, swapping the position would be able to overcome this problem.

  • HT1449 how do you move all music from two computers into one itunes account?

    How do you move all music from two computers into one itunes account?

    An "iTunes account" is an online account you use for buying music, like a bank account.  An iTunes collection is the media you see when you open iTunes. Which do you mean?
    If it is two computers, it would also help to know where these are located. Are they on the same local network? If they are, try Home Sharing (and you have control of both and you aren't just trying to get music fro your computer to your friend's computer in another state).  If they are not, you'll have to use an external hard drive or flash drive.
    Is this on a PC? Your computer information says Windows but you posted this in the iTunes for Mac forum.

  • How to get the selection parameters from logical database into one of the t

    Hi Sap ABAP Champians,
    How to get the selection parameters from logical database into one of the tab in the tabstrip selection-screen.
    Please help me for this
    Thanks
    Basu

    Hi
    Thanks, that will work, but then I'll have to insert code into all my reports.
    I can see that "Application Server Control Console" is able to rerun a report.
    This must mean that the Report Server has access to the runtime parameters.
    But how?
    Cheers
    Nils Peter

Maybe you are looking for