Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Array within array out to CSV

$
0
0

Hi all,

I'm having some trouble understanding how I can get my array output information into CSV.

I've written a small script to read a file and populate an array of Analysis Services Servers, for each server I list the Cube content and a few data items relating to each cube but I'm unable to get the content out to CSV. I've tried a holding array of PSObject items and I can get some characters to output but not the entire string.

Would it be possible for someone to explain where I'm going wrong on this? I think it is my understanding of the array content. The items are AS objects but even when I convert them to PSObjects they still will not output as a full line to CSV.

Thanks in advance for any help.

------------------------

clear-host

 

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") > $NULL

$Server = New-Object Microsoft.AnalysisServices.Server

If ($? -eq $False)

      {

            EXIT

    }

 

# Create new object of the assembly

$srv = new-object Microsoft.AnalysisServices.Server

 

#Get server instance by parameter

$Instances = Get-Content -Path "D:\ETL\SSAS_Servers\servers.csv"

 

      foreach($AShost in $Instances)

      {

            # Connect to server

            $srv.Connect($AShost)

 

# Print server name

$srv.Name

# Print cube details

           foreach($db in $srv.Databases)

           {

               $db.Name

               $db.CreatedTimestamp

               $db.LastProcessed

               $db.LastSchemaUpdate

               $db.State

#Export-Csv D:\ETL\SSAS_Servers\cubes.csv -NoTypeInformation

 

           } 

 

            # Disconnect server

            if ($srv.Connected)

            {

            $srv.Disconnect()

            }

 

      }


Viewing all articles
Browse latest Browse all 10624

Trending Articles