Error: $customObject | format-table

I see this problem all over but have tried every proposed solution but 
nothing provided works for me.  Bottom line, I am creating a custom object 
via .csv import but when trying to format-(to anything), I get the error 
shown below the script.  Sorry if this is a dead-horse.  BTW...using v2 on 
W2K8R2.  Everything works except the last line.  If the "ft" is not there, 
the results are listed in "format-list" by default...but I want a table 
format.  (Script below is word-wrapped of course".

###Beginning of script
param([SWITCH]$help, [STRING]$ouDN, [STRING]$file)


###################################################### Functions
#####################################################
Function get_help()
{
$helpText=@"
"@
write-host $helpText -ForegroundColor Yellow
exit
}

###################################################### Validate parameters 
and combinations
#####################################################
if ($help -or $param.count -eq 0) {get_help}

###################################################### Functions
###################################################### Function to verify 
the passed OU exists
#####################################################
function verify_OU
{
	$ErrorActionPreference = "SilentlyContinue"
	
	$ouExist = [ADSI]::Exists("LDAP://" + $ouDN)
	while ($ouExist -ne $TRUE)
	{
		Write-Warning "Specified OU does not exist: $ouPath"
		$ouDN = Read-Host "Retype target OU distinguishedName path"
		$ouExist = [ADSI]::Exists("LDAP://" + $ouDN)
    set-variable -name ouDN -value "$ouDN" -scope 1
	}
}

###################################################### Function to collect 
computer object information from AD
#####################################################
function get_computerObjectInfo
{
  #set variable values to default of NULL
  $computerDnsHostName = "NULL"
  $computerOS = "NULL"
  $computerLLTS = "NULL"
  
  #collect computer dnsHostName
  if ($computer.dnshostname -ne $null)
  {
    $computerDnsHostName = $computer.dnshostname
  }
  #collect computer operatingSystem
  if ($computer.operatingsystem -ne $null)
  {
    $computerOS = $computer.operatingsystem
  }
  #collect computer lastLogonTimeStamp
  if ($computer.lastLogonTimeStamp -ne $null)
  {
    $computerLLTS = Get-Date -Date 
([DateTime]::FromFileTime([Int64]::Parse($computer.lastLogonTimeStamp)))`
      -Format MM/dd/yyyy
  }  
  $SCRIPT:adResults = 
"$computerName,$computerDnsHostName,$computerOS,$computerLLTS"
}

###################################################### Function to ping 
computer
#####################################################
function ping_computer
{
  PROCESS
  {
    trap { continue }
    $pingStatus = $ping.send($computerName).status
    if ($pingStatus -eq "Success")
    {
      $pingResponse = ("Online")
    }
    else
    {
      $pingResponse = ("Offline")
    }
  }
  END
  {
    $SCRIPT:pingResults = $pingResponse
  }
}

###################################################### Verifty script 
execution pre-requisits
#####################################################
verify_ou

Import-Module activedirectory

###################################################### Create .csv files
#####################################################$csvPath = Get-Location
$csvFile = $csvPath.Path + "\computerInfo.csv"

New-Item $csvFile -type file -Force
Set-Content $csvFile 
"name,dnsHostName,operatingSystem,lastLogonTimeStamp,pingStatus"
#Clear-Host

#####################################################
# Main
#####################################################
$ping = new-object System.Net.NetworkInformation.Ping

$computers = get-adcomputer -filter * -searchBase $ouDN -resultpagesize 1000 
-searchScope subtree -Properties 
lastLogonTimeStamp,name,operatingsystem,dnshostname

foreach ($computer in $computers)
{
  $computerName = $computer.name
  get_computerObjectInfo
  ping_computer
  "$adResults,$pingResults"
  Add-Content $csvFile "$adResults,$pingResults"
}

$colComputers = @()

$colComputerInput = Import-Csv -Path $csvFile

foreach ($objComputer in $colComputerInput)
  {
    $objComputerInfo = New-Object System.Object
    $objComputerInfo | Add-Member -MemberType NoteProperty -name 
computername -value $objComputer.name
    $objComputerInfo | Add-Member -MemberType NoteProperty -name dnsHostName 
-value $objComputer.dnsHostName
    $objComputerInfo | Add-Member -MemberType NoteProperty -name 
operatingSystem -value $objComputer.operatingSystem
    $objComputerInfo | Add-Member -MemberType NoteProperty -name 
lastLogonTimeStamp -value $objComputer.lastLogonTimeStamp
    $objComputerInfo | Add-Member -MemberType NoteProperty -name pingStatus 
-value $objComputer.pingStatus
    $colComputers += $objComputerInfo
  }

$colComputers | ft   ###<---This is causing the below error
###End of script


##########
out-linoutput : The object of type 
"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid 
or not in the correct sequence.  This is likely caused by a user-specified 
"format-table" command which is conflicting with the default formatting.

+ CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException
+ FullyQualifiedErrorId : 
ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
##########

Help...why? and how can easily resolve.  Thanks.

Paul
0
Utf
6/23/2010 3:17:04 AM
windows.powershell 690 articles. 0 followers. Follow

1 Replies
1304 Views

Similar Articles

[PageSpeed] 25

UPDATE: This error only appears if I write to the file first.  I commented 
out all the logic to create/write to "computerInfo.csv" and just left the 
script to read from the data that was already in there.  Voila...out put was 
returned as desired using format-*.

Is it possible I have a streaming or "file-state" conflict where the file 
must be explicitly closed prior to reading the contents back in?  If so, how 
do I explicitly close?  Thanks!

Paul

__________

"Paul B. (USAF)" wrote:

> I see this problem all over but have tried every proposed solution but 
> nothing provided works for me.  Bottom line, I am creating a custom object 
> via .csv import but when trying to format-(to anything), I get the error 
> shown below the script.  Sorry if this is a dead-horse.  BTW...using v2 on 
> W2K8R2.  Everything works except the last line.  If the "ft" is not there, 
> the results are listed in "format-list" by default...but I want a table 
> format.  (Script below is word-wrapped of course".
> 
> ###Beginning of script
> param([SWITCH]$help, [STRING]$ouDN, [STRING]$file)
> 
> 
> ###################################################### Functions
> #####################################################
> Function get_help()
> {
> $helpText=@"
> "@
> write-host $helpText -ForegroundColor Yellow
> exit
> }
> 
> ###################################################### Validate parameters 
> and combinations
> #####################################################
> if ($help -or $param.count -eq 0) {get_help}
> 
> ###################################################### Functions
> ###################################################### Function to verify 
> the passed OU exists
> #####################################################
> function verify_OU
> {
> 	$ErrorActionPreference = "SilentlyContinue"
> 	
> 	$ouExist = [ADSI]::Exists("LDAP://" + $ouDN)
> 	while ($ouExist -ne $TRUE)
> 	{
> 		Write-Warning "Specified OU does not exist: $ouPath"
> 		$ouDN = Read-Host "Retype target OU distinguishedName path"
> 		$ouExist = [ADSI]::Exists("LDAP://" + $ouDN)
>     set-variable -name ouDN -value "$ouDN" -scope 1
> 	}
> }
> 
> ###################################################### Function to collect 
> computer object information from AD
> #####################################################
> function get_computerObjectInfo
> {
>   #set variable values to default of NULL
>   $computerDnsHostName = "NULL"
>   $computerOS = "NULL"
>   $computerLLTS = "NULL"
>   
>   #collect computer dnsHostName
>   if ($computer.dnshostname -ne $null)
>   {
>     $computerDnsHostName = $computer.dnshostname
>   }
>   #collect computer operatingSystem
>   if ($computer.operatingsystem -ne $null)
>   {
>     $computerOS = $computer.operatingsystem
>   }
>   #collect computer lastLogonTimeStamp
>   if ($computer.lastLogonTimeStamp -ne $null)
>   {
>     $computerLLTS = Get-Date -Date 
> ([DateTime]::FromFileTime([Int64]::Parse($computer.lastLogonTimeStamp)))`
>       -Format MM/dd/yyyy
>   }  
>   $SCRIPT:adResults = 
> "$computerName,$computerDnsHostName,$computerOS,$computerLLTS"
> }
> 
> ###################################################### Function to ping 
> computer
> #####################################################
> function ping_computer
> {
>   PROCESS
>   {
>     trap { continue }
>     $pingStatus = $ping.send($computerName).status
>     if ($pingStatus -eq "Success")
>     {
>       $pingResponse = ("Online")
>     }
>     else
>     {
>       $pingResponse = ("Offline")
>     }
>   }
>   END
>   {
>     $SCRIPT:pingResults = $pingResponse
>   }
> }
> 
> ###################################################### Verifty script 
> execution pre-requisits
> #####################################################
> verify_ou
> 
> Import-Module activedirectory
> 
> ###################################################### Create .csv files
> #####################################################$csvPath = Get-Location
> $csvFile = $csvPath.Path + "\computerInfo.csv"
> 
> New-Item $csvFile -type file -Force
> Set-Content $csvFile 
> "name,dnsHostName,operatingSystem,lastLogonTimeStamp,pingStatus"
> #Clear-Host
> 
> #####################################################
> # Main
> #####################################################
> $ping = new-object System.Net.NetworkInformation.Ping
> 
> $computers = get-adcomputer -filter * -searchBase $ouDN -resultpagesize 1000 
> -searchScope subtree -Properties 
> lastLogonTimeStamp,name,operatingsystem,dnshostname
> 
> foreach ($computer in $computers)
> {
>   $computerName = $computer.name
>   get_computerObjectInfo
>   ping_computer
>   "$adResults,$pingResults"
>   Add-Content $csvFile "$adResults,$pingResults"
> }
> 
> $colComputers = @()
> 
> $colComputerInput = Import-Csv -Path $csvFile
> 
> foreach ($objComputer in $colComputerInput)
>   {
>     $objComputerInfo = New-Object System.Object
>     $objComputerInfo | Add-Member -MemberType NoteProperty -name 
> computername -value $objComputer.name
>     $objComputerInfo | Add-Member -MemberType NoteProperty -name dnsHostName 
> -value $objComputer.dnsHostName
>     $objComputerInfo | Add-Member -MemberType NoteProperty -name 
> operatingSystem -value $objComputer.operatingSystem
>     $objComputerInfo | Add-Member -MemberType NoteProperty -name 
> lastLogonTimeStamp -value $objComputer.lastLogonTimeStamp
>     $objComputerInfo | Add-Member -MemberType NoteProperty -name pingStatus 
> -value $objComputer.pingStatus
>     $colComputers += $objComputerInfo
>   }
> 
> $colComputers | ft   ###<---This is causing the below error
> ###End of script
> 
> 
> ##########
> out-linoutput : The object of type 
> "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid 
> or not in the correct sequence.  This is likely caused by a user-specified 
> "format-table" command which is conflicting with the default formatting.
> 
> + CategoryInfo : InvalidData: (:) [out-lineoutput], InvalidOperationException
> + FullyQualifiedErrorId : 
> ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
> ##########
> 
> Help...why? and how can easily resolve.  Thanks.
> 
> Paul
0
Utf
6/23/2010 11:52:55 AM
Reply:

Similar Artilces:

Excel Progrom Error
Hi there Happy new year to all. I often receive the folowing error message in a box titled "Program Error". EXCEL.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created. The only option is OK which closes Excel. I do not know where the error log is created. I am using Office 2000 Service Pack 3 with Windows 2000 Professsional Service Pack 4. Can anybody throw some light on this error. Thanks in anticipation. Michael What are you doing at the time (i.e. is it consistent)? -- Regards; Rob ----------------...

Sharebuilder account import error
Invalid .qif header error when trying to import .qif file from sharebuilder accounts. Anyone know of a fix or experienced this problem?? I typed a long mail to sharebuilder regarding this issue...still waiting fora reply. Hopefully they will be able to help. Microsoft flat out told me it wasn't their issue and to contact my broker! No help AT ALL. Microshaft..... OMalley ...

DPM2010 RC Errors on secondary server.
We have recently upraded our 2007 SP1 Primary DPM server to 2010 RC and it is working perfectly. I've set up a brand new, fresh Windows 2008 R2 Server for the secondary server, and have told it to protect one of the protection groups on the primary server. Everything works for a little while, but every half hour or so, the DPM service crashes and says: "Connection to the DPM service has been lost. Review the application event log for information about a possible service shutdown. ID: 917" Then asks to restart the administrator console. This kills the ...

ERROR
Hi I am using a spreadsheet in Excel 2002 on Windows XP, for some reason the account numbers (which someone input, along with addresses) have a little green mark in the corner of the cell. I thought it was to show that there is a comment, but it is not. When you click on the cell, a little warning sign shows, saying ERROR - number in this cell formatted as text or preceded by an apostrophe. When I click on the arrow by the warning sign, it says Number stored as text Convert to number Ignore error Edit in formula bar Error checking options Show formula in audinting toolbar Now I looked a...

error, chkdsk
Questio, when I try to open excel or winmx, an error pops up saying chkdsk, so i ran a chkdsk and it doesnt do anything. The error also says corrupted file. In excel I have some important work that I need to open, and it only opens in Turkish, if I change it to English, its a bunch of boxes and letters, its not my work I need. How do I change it back. What excel version are you using? Try to find somebody with 2003 to see if they can open the file. Otherwise you would look for some commercial software that might be of help http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B30...

4.4.7 error
I have problems on one client that they don't recieve all emails from people sending to them. I guess something is wrong in the configuration. When I do a nslookup -type=mx domain.com I just get unautharized answer. Also the ttl time is just 1800 when I do a dns report. Do the guys that handle the dns change this? The people that doesn't get their mail throw get the 4.4.7 error in return. Best regards Jimmy http://support.microsoft.com/kb/555375 -- Ed Crowley MVP "There are seldom good technological solutions to behavioral problems." .. "Surfer&q...

error 0x800CCC0F
Dear Team; I am receiving the following error messages, please assist Could result be sent to lewis.king@riotinto.com regards Lew Your server has unexpectedly terminated the connection. Possible causes for this include server problems, network problems, or a long period of inactivity. Subject 'brocolli & mushroom stir fry noodle', Account: 'pop.gmail.com', Server: 'smtp.gmail.com', Protocol: SMTP, Port: 995, Secure(SSL): Yes, Error Number: 0x800CCC0F Your server has unexpectedly terminated the connection. Possible causes for this include server p...

html format email
How can I, if possible, create html formatted email and/or email templates in crm? I can write some custom add-ins in c# if needed. Thanks, J On Sat, 26 Feb 2005 08:41:24 -0500, "Scanner2001" <jeffsanders125@hotmail.com> wrote: > How can I, if possible, create html formatted email and/or email >templates in crm? You can create html email templates. The secret is to create them in another tool eg Notepad or Dreamweaver then open the html in IE and then cut and paste into the CRM email template window If you have graphics only links to the images are copie...

delete server...routing master error
hello, I have 2 exchange servers (exch 2003) and i have to delete one of them. I changed all replication etc...(before we had also a 5.5 which is already removed) but when i stop the services and try to remove the server via system manager of my second exchange (the one that will stay) i get an error message that my server that i want to delete is the routing master for that group. How can i make my other server the routing master ? i don't have any site replication (deleted it because not necessary anymore). thnx, Philippe Go to routing groups > first routing group > mem...

Excel error codes translations
hi, Does anybody know where I can find a kind of dictionary for Exce errors? The problem is sometimes I get an error message that is not in Englis and without error code and then looking for the solution I must kno its equivalent in English. Regards, Micha -- Message posted from http://www.ExcelForum.com ...

toolbar, date, services, errors, paste, minimized system restore doesn't work
I have a XP system that the toolbar does not show open programs, services do not seem to load at boot, the date is off by one month, I cannot paste anything that I copy, and system restore does not work. All of these issues started at the same time a few days ago. Has anyone else seen this group of errors? I am trying to resolve and do not know if it is a system update gone bad, or if maybe it is a viruse/malware issue. Please let me know if you had had these problems together and what you did to fix them. There is a very good chance that you are seeing the effects of a hi...

Re: Money 2004
Thanks for the suggestion. I tried unregistering/re-registering the msxml3 DLL, but still no luck. However, knowing the help file topics are local might help with debugging this problem. thanks, randy "Randy" <nospam@hotmail.com> wrote in message news:... > All, > > I've recently upgraded to Money 2004 Premium from 2003 Deluxe. I'm now > finding that I can't view any help topics--I get the "Unable to load topic. > Click here to try again." I've tried all the suggestions posted here and at > other sites: cleared out temporary in...

"File Error: Data May Be Lost" error when opening workbook saved in Mac
When I open in Excel 2007 for Windows workbook with charts saved in Mac OS, I see the message "File Error: Data May Be Lost". In Excel 2003 for Windows this message appears as many times as many sheets there are in workbook. Maybe someone knows what's the reason? Unfortunately you haven't provided the info needed... "Mac OS" means very little. The question is "What version of Mac Excel are you using, what file format are the files saved as & what type of content is in the files?" In general, what you're running into is that Excel 2003 &a...

Formatting issues with downloaded spreadsheet
I have a spreadsheet I downloaded and when I try to format one of the numbers using the comma style button, the cell turns to text and becomes shaded gray. Another program I download from won't let me use any of the buttons (I can click them but nothing happnes) and I have to go though the menu to do the formatting. Is there some kind of option or setting that I need to change to get the spreadsheet working normally again ? thanks in advance ! Gary Where did you download it from? what button are you talking about? what do the buttons do? >-----Original Message----- >I ha...

Technical error
AMEX and Discover are not being sent over to the credit card processor during settlement. I comes up with a "TECHNICAL ERROR". Visa and MC are settling fine. Does anyone know what the problem is?? All are setup as different tranaction types in RMS and ALL authorize fine during the transaction process. Your merchant account is not correctly configured for AMEX & Discover. This is on the bank's side, not RMS. -- Glenn Adams Tiber Creek Consulting http://www.tibercreek.com glenn@tibercreek.com ---------------------------------------------- Please DO NOT respond to me dir...

CObject Private method access error
Hi, I am trying to recompile application that has been developed in VC++ 6.0 with VC++2005.. While compiling, I'm getting the following error.. error C2248: 'CObject::CObject' : cannot access private member declared in class 'CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(553) : see declaration of 'CObject::CObject' 1> c:\program files\microsoft visual studio 8\vc\atlmfc\include\afx.h(524) : see declaration of 'CObject' 1> This diagnostic occurred in the compiler generated function 'CExcepti...

How do I format text as a hyperlink in Excel
I want up to 1,00o cells in a single Excel worksheet to display as hyperlinks to general web addresses (mainly home pages). Each cell is a different web address. How do I format the Excel cells to display and act as a hyperlink? The formula to use is =HYPERLINK(actual_address, friendly_address) where actual_address is the full link to the website (or other excel sheets/files), and friendly_address is what is shown in the Excel cell - underlined and coloured blue. If friendly_address is missing, the actual_address is shown. Hope this helps. Pete Pete Thanks for this BUT I already hav...

Error in closing Outlook
Application error ciceroUIWndFrame. The instruction at 0x7e430240 reference memory cannot be written 0x7e42631A Also unable to dial a phone using Outlook. Sanford Take a look here http://support.microsoft.com/kb/323613 -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "Sanford Aranoff" <aranoff@analysis-knowledge.com> wrote in message news:4B6CD165.E7510293@analysis-knowledge.com... > Application error ciceroUIWndFrame. > The instruction at 0x7e430240 reference me...

Typing message error
I have an Asus Eee PC netbook which came with a Microsoft Works 2007 trial. I'm unable to type anything on a Word document. An error message flashes briefly at the bottom of the screen, "This modification is not allowed because the selection is locked." I'm baffled. Is this a computer problem or a Works problem and how can this be fixed? Thank you. I would be surprised if any system nowadays came with a Works trial; more likely it is an Office 2007 trial (and if it *is* Works, then you're in the wrong discussion group). If the computer is quite new, then...

Can't Erase Tapes: DPM Fails with Error ID:3308
I attempt to erase a tape and every time the DPM console crashes (sometimes two hours into the tape erase) and there is this error: * (000002L4) could not be erased for the following reason: (ID 3308) * DPM service terminated unexpectedly during completion of the job. The termination may have been caused by a system reboot. (ID 910) I can verify that the server has not rebooted. I'm using DPM 2007, with June Rollup, on Windows Server (x64) 2008. The server is a Dell PowerEdge R710. The tape drive is an LTO4 in a Dell PowerVault 124T Autoloader. This error seems to ...

PM Transaction continuing error message #2
We are currently running GP 10 SP1 and apparently since version 8 (we did not upgrade to 9) there has been the following error message while launching a transaction out of Smartlist, when we go to inquiry for AP documents, and drill down of PMTRX & PMCHK from the JE inquiry view: Unhandeled Script Exception: Index 0 array of 'PM_Transaction_Inquiry_Fill' Script terminated We ran a query for all documents that were less than 1 or greater the 8 on the PM00400 & PM30200 tables. And updated the ones to what they needed to be. And it worked! And the message went away! But then we ...

outlook.pst error message
When I attmept to open Outlook 2000 (in Windows XP) I get an error message that the file C:Documents and Setting\Owner Settings\Application Data\Microsoft\Outlook\outlook.pst has detetected an error. It tells me to quit all mail-enabled applications and then use the Inbox repair tool. I have tried to run the repair tool many times and it always crashes before it fin9shes scanning the files. One time it finished the scan and stated that files were damaged and it asked if I wanted to Repair those files. I said yes and it froze up and would not respond. Are there any other ways ...

Expand Conditional Formatting to all Rows
I cannot get my conditional formatting rule to apply to my entire data set. My data are set in rows. I want the entire row to format (color fill) when two specific cells within that row equal each other. I can get the single row to work properly, but I can't see how to expand this formula down to each row on my worksheet. I have read several other posts regarding this issue but am still not able to get it to work, can someone help me out? -- KKD Have you tried using the format painter which is probably on your tool bar. Looks like a paint brush -- Don Guillett M...

Set character specificiations for field in a table
Hello, I am working in a table in MS Access 2003 and one of my fields is store number. Stores are either a 3- or a 4-digit number (ex. 111, 1234). I have the data type set as text, but I can change it to number if it needs to be. Is there a way that I can set the field properties for the store number field so that the store number will always appear as a 4-digit number and if the store has only 3-digits it has a leading zero? Basically, if it is 4-digits already it will appear as is (ex. 1234), but if it is only 3-digits it will look like this: 0111. Any help you can prov...

probably a simple table problem
Hi there. Ok, I have a table with 5 columns which I keep the data in. On another sheet I want a table which arranges the data from that tabl in ascending order, and throws out the values which have a 0 in it. Here's an example Barn - 1 - 0 - 1 - 2 farm - 0 - 2 - 1 - 0 firm - 2 - 1 - 0 - 0 A drop-down list picks if you arrange the data depending on column 2 3, 4 or 5. Column 1 is never listed as a choice (of course, as it' just the name for the thing). Let's say we pick column 1, then the table I want puts firm at the top then barn, and doesn't show farm. How can I do th...