Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Scripting bug?

Reply
 
Old 06-28-2006   #1 (permalink)
Chris Warwick


 
 

Scripting bug?

Inspired by MOW's Active Directory blogs I thought I'd have a look at
my own domain, but I'm seeing something unusual with a script and
wonder if this is a bug? Can anyone reproduce? Is it just me?!

I've cut down the original script to illustrate the problem:

#---------Script (WORKS)
# Show info about the current domain.

$Domain=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()

$DCs=$Domain.DomainControllers

"Domain Name: " + $Domain.Name
#$Domain ### <------ Note comment

"`nDomain Controllers"
$DCs | Format-Table Name, IPAddress, SiteName
#------------------

Gives:

MSH> C:\Data\PowerShell\dom-info2.ps1
Domain Name: xxxxx.com


Domain Controllers

Name IPAddress SiteName
---- --------- --------
sirius.xxxxx.com 192.168.0.246 Harwell
IO.xxxxx.com 192.168.0.220 Harwell


But if I remove the comment from the line indicated above, the output
changes to:

MSH> C:\Data\PowerShell\dom-info2.ps1
Domain Name: xxxxx.com


Forest : xxxxx.com
DomainControllers : {sirius.xxxxx.com, IO.xxxxx.com}
Children : {}
DomainMode : Windows2003Domain
Parent :
PdcRoleOwner : sirius.xxxxx.com
RidRoleOwner : sirius.xxxxx.com
InfrastructureRoleOwner : sirius.xxxxx.com
Name : xxxxx.com



Domain Controllers
out-lineoutput : Object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
legal or not in the correct sequence. This is likely cau
sed by a user-specified "format-table" command which is conflicting
with the default formatting.

Any ideas?

Thanks
Chris

My System SpecsSystem Spec
Old 06-28-2006   #2 (permalink)
Chris Warwick


 
 

Re: Scripting bug?

Incidentally, I forgot to mention that if I type the lines of the
script as shown into the console directly I get the output you would
expect; I only see a problem when I execute the commands from a .PS1
file???



On Wed, 28 Jun 2006 10:46:11 +0100, Chris Warwick
<news@remove.this.bit.nuney.com> wrote:

>Inspired by MOW's Active Directory blogs I thought I'd have a look at
>my own domain, but I'm seeing something unusual with a script and
>wonder if this is a bug? Can anyone reproduce? Is it just me?!
>
>I've cut down the original script to illustrate the problem:
>
>#---------Script (WORKS)
># Show info about the current domain.
>
>$Domain=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
>
>$DCs=$Domain.DomainControllers
>
>"Domain Name: " + $Domain.Name
>#$Domain ### <------ Note comment
>
>"`nDomain Controllers"
>$DCs | Format-Table Name, IPAddress, SiteName
>#------------------
>
>Gives:
>
>MSH> C:\Data\PowerShell\dom-info2.ps1
>Domain Name: xxxxx.com
>
>
>Domain Controllers
>
>Name IPAddress SiteName
>---- --------- --------
>sirius.xxxxx.com 192.168.0.246 Harwell
>IO.xxxxx.com 192.168.0.220 Harwell
>
>
>But if I remove the comment from the line indicated above, the output
>changes to:
>
>MSH> C:\Data\PowerShell\dom-info2.ps1
>Domain Name: xxxxx.com
>
>
>Forest : xxxxx.com
>DomainControllers : {sirius.xxxxx.com, IO.xxxxx.com}
>Children : {}
>DomainMode : Windows2003Domain
>Parent :
>PdcRoleOwner : sirius.xxxxx.com
>RidRoleOwner : sirius.xxxxx.com
>InfrastructureRoleOwner : sirius.xxxxx.com
>Name : xxxxx.com
>
>
>
>Domain Controllers
>out-lineoutput : Object of type
>"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
>legal or not in the correct sequence. This is likely cau
>sed by a user-specified "format-table" command which is conflicting
>with the default formatting.
>
>Any ideas?
>
>Thanks
>Chris

My System SpecsSystem Spec
Old 06-28-2006   #3 (permalink)
Aspa


 
 

Re: Scripting bug?

interesting, I tried the same, with the same result.
So then I tried something simulair like:
#--------------------
##processes.ps1##
$processes=gps
$processes
$processes|ft processname,id,handles
#--------------------

this produces exactly the same error.
It only seems to appear when you use a variable in a script and then pipe
that same variable to a format-table or a format-list. (both result in the
same error)
> >out-lineoutput : Object of type
> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
> >legal or not in the correct sequence. This is likely cau
> >sed by a user-specified "format-table" command which is conflicting
> >with the default formatting.


anybody any sugestions?

Grt
Dennis



"Chris Warwick" wrote:

> Incidentally, I forgot to mention that if I type the lines of the
> script as shown into the console directly I get the output you would
> expect; I only see a problem when I execute the commands from a .PS1
> file???
>
>
>
> On Wed, 28 Jun 2006 10:46:11 +0100, Chris Warwick
> <news@remove.this.bit.nuney.com> wrote:
>
> >Inspired by MOW's Active Directory blogs I thought I'd have a look at
> >my own domain, but I'm seeing something unusual with a script and
> >wonder if this is a bug? Can anyone reproduce? Is it just me?!
> >
> >I've cut down the original script to illustrate the problem:
> >
> >#---------Script (WORKS)
> ># Show info about the current domain.
> >
> >$Domain=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
> >
> >$DCs=$Domain.DomainControllers
> >
> >"Domain Name: " + $Domain.Name
> >#$Domain ### <------ Note comment
> >
> >"`nDomain Controllers"
> >$DCs | Format-Table Name, IPAddress, SiteName
> >#------------------
> >
> >Gives:
> >
> >MSH> C:\Data\PowerShell\dom-info2.ps1
> >Domain Name: xxxxx.com
> >
> >
> >Domain Controllers
> >
> >Name IPAddress SiteName
> >---- --------- --------
> >sirius.xxxxx.com 192.168.0.246 Harwell
> >IO.xxxxx.com 192.168.0.220 Harwell
> >
> >
> >But if I remove the comment from the line indicated above, the output
> >changes to:
> >
> >MSH> C:\Data\PowerShell\dom-info2.ps1
> >Domain Name: xxxxx.com
> >
> >
> >Forest : xxxxx.com
> >DomainControllers : {sirius.xxxxx.com, IO.xxxxx.com}
> >Children : {}
> >DomainMode : Windows2003Domain
> >Parent :
> >PdcRoleOwner : sirius.xxxxx.com
> >RidRoleOwner : sirius.xxxxx.com
> >InfrastructureRoleOwner : sirius.xxxxx.com
> >Name : xxxxx.com
> >
> >
> >
> >Domain Controllers
> >out-lineoutput : Object of type
> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
> >legal or not in the correct sequence. This is likely cau
> >sed by a user-specified "format-table" command which is conflicting
> >with the default formatting.
> >
> >Any ideas?
> >
> >Thanks
> >Chris

>

My System SpecsSystem Spec
Old 06-28-2006   #4 (permalink)
Chris Warwick


 
 

Re: Scripting bug?

Glad it's not just me!

With my example below it's not even the SAME variable, I have:

> >"Domain Name: " + $Domain.Name
> >$Domain
> >$DCs | Format-Table Name, IPAddress, SiteName


(Although the $DCs variable is originally derived from the $Domain)





On Wed, 28 Jun 2006 04:17:02 -0700, Aspa
<Aspa@discussions.microsoft.com> wrote:

>interesting, I tried the same, with the same result.
>So then I tried something simulair like:
>#--------------------
>##processes.ps1##
>$processes=gps
>$processes
>$processes|ft processname,id,handles
>#--------------------
>
>this produces exactly the same error.
>It only seems to appear when you use a variable in a script and then pipe
>that same variable to a format-table or a format-list. (both result in the
>same error)
>> >out-lineoutput : Object of type
>> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
>> >legal or not in the correct sequence. This is likely cau
>> >sed by a user-specified "format-table" command which is conflicting
>> >with the default formatting.

>
>anybody any sugestions?
>
>Grt
>Dennis
>
>
>
>"Chris Warwick" wrote:
>
>> Incidentally, I forgot to mention that if I type the lines of the
>> script as shown into the console directly I get the output you would
>> expect; I only see a problem when I execute the commands from a .PS1
>> file???
>>
>>
>>
>> On Wed, 28 Jun 2006 10:46:11 +0100, Chris Warwick
>> <news@remove.this.bit.nuney.com> wrote:
>>
>> >Inspired by MOW's Active Directory blogs I thought I'd have a look at
>> >my own domain, but I'm seeing something unusual with a script and
>> >wonder if this is a bug? Can anyone reproduce? Is it just me?!
>> >
>> >I've cut down the original script to illustrate the problem:
>> >
>> >#---------Script (WORKS)
>> ># Show info about the current domain.
>> >
>> >$Domain=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
>> >
>> >$DCs=$Domain.DomainControllers
>> >
>> >"Domain Name: " + $Domain.Name
>> >#$Domain ### <------ Note comment
>> >
>> >"`nDomain Controllers"
>> >$DCs | Format-Table Name, IPAddress, SiteName
>> >#------------------
>> >
>> >Gives:
>> >
>> >MSH> C:\Data\PowerShell\dom-info2.ps1
>> >Domain Name: xxxxx.com
>> >
>> >
>> >Domain Controllers
>> >
>> >Name IPAddress SiteName
>> >---- --------- --------
>> >sirius.xxxxx.com 192.168.0.246 Harwell
>> >IO.xxxxx.com 192.168.0.220 Harwell
>> >
>> >
>> >But if I remove the comment from the line indicated above, the output
>> >changes to:
>> >
>> >MSH> C:\Data\PowerShell\dom-info2.ps1
>> >Domain Name: xxxxx.com
>> >
>> >
>> >Forest : xxxxx.com
>> >DomainControllers : {sirius.xxxxx.com, IO.xxxxx.com}
>> >Children : {}
>> >DomainMode : Windows2003Domain
>> >Parent :
>> >PdcRoleOwner : sirius.xxxxx.com
>> >RidRoleOwner : sirius.xxxxx.com
>> >InfrastructureRoleOwner : sirius.xxxxx.com
>> >Name : xxxxx.com
>> >
>> >
>> >
>> >Domain Controllers
>> >out-lineoutput : Object of type
>> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
>> >legal or not in the correct sequence. This is likely cau
>> >sed by a user-specified "format-table" command which is conflicting
>> >with the default formatting.
>> >
>> >Any ideas?
>> >
>> >Thanks
>> >Chris

>>

My System SpecsSystem Spec
Old 06-28-2006   #5 (permalink)
Aspa


 
 

Re: Scripting bug?


> (Although the $DCs variable is originally derived from the $Domain)


That's the key, so actually it IS the same :-)

Dennis


"Chris Warwick" wrote:

> Glad it's not just me!
>
> With my example below it's not even the SAME variable, I have:
>
> > >"Domain Name: " + $Domain.Name
> > >$Domain
> > >$DCs | Format-Table Name, IPAddress, SiteName

>
> (Although the $DCs variable is originally derived from the $Domain)
>
>
>
>
>
> On Wed, 28 Jun 2006 04:17:02 -0700, Aspa
> <Aspa@discussions.microsoft.com> wrote:
>
> >interesting, I tried the same, with the same result.
> >So then I tried something simulair like:
> >#--------------------
> >##processes.ps1##
> >$processes=gps
> >$processes
> >$processes|ft processname,id,handles
> >#--------------------
> >
> >this produces exactly the same error.
> >It only seems to appear when you use a variable in a script and then pipe
> >that same variable to a format-table or a format-list. (both result in the
> >same error)
> >> >out-lineoutput : Object of type
> >> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
> >> >legal or not in the correct sequence. This is likely cau
> >> >sed by a user-specified "format-table" command which is conflicting
> >> >with the default formatting.

> >
> >anybody any sugestions?
> >
> >Grt
> >Dennis
> >
> >
> >
> >"Chris Warwick" wrote:
> >
> >> Incidentally, I forgot to mention that if I type the lines of the
> >> script as shown into the console directly I get the output you would
> >> expect; I only see a problem when I execute the commands from a .PS1
> >> file???
> >>
> >>
> >>
> >> On Wed, 28 Jun 2006 10:46:11 +0100, Chris Warwick
> >> <news@remove.this.bit.nuney.com> wrote:
> >>
> >> >Inspired by MOW's Active Directory blogs I thought I'd have a look at
> >> >my own domain, but I'm seeing something unusual with a script and
> >> >wonder if this is a bug? Can anyone reproduce? Is it just me?!
> >> >
> >> >I've cut down the original script to illustrate the problem:
> >> >
> >> >#---------Script (WORKS)
> >> ># Show info about the current domain.
> >> >
> >> >$Domain=[System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
> >> >
> >> >$DCs=$Domain.DomainControllers
> >> >
> >> >"Domain Name: " + $Domain.Name
> >> >#$Domain ### <------ Note comment
> >> >
> >> >"`nDomain Controllers"
> >> >$DCs | Format-Table Name, IPAddress, SiteName
> >> >#------------------
> >> >
> >> >Gives:
> >> >
> >> >MSH> C:\Data\PowerShell\dom-info2.ps1
> >> >Domain Name: xxxxx.com
> >> >
> >> >
> >> >Domain Controllers
> >> >
> >> >Name IPAddress SiteName
> >> >---- --------- --------
> >> >sirius.xxxxx.com 192.168.0.246 Harwell
> >> >IO.xxxxx.com 192.168.0.220 Harwell
> >> >
> >> >
> >> >But if I remove the comment from the line indicated above, the output
> >> >changes to:
> >> >
> >> >MSH> C:\Data\PowerShell\dom-info2.ps1
> >> >Domain Name: xxxxx.com
> >> >
> >> >
> >> >Forest : xxxxx.com
> >> >DomainControllers : {sirius.xxxxx.com, IO.xxxxx.com}
> >> >Children : {}
> >> >DomainMode : Windows2003Domain
> >> >Parent :
> >> >PdcRoleOwner : sirius.xxxxx.com
> >> >RidRoleOwner : sirius.xxxxx.com
> >> >InfrastructureRoleOwner : sirius.xxxxx.com
> >> >Name : xxxxx.com
> >> >
> >> >
> >> >
> >> >Domain Controllers
> >> >out-lineoutput : Object of type
> >> >"Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not
> >> >legal or not in the correct sequence. This is likely cau
> >> >sed by a user-specified "format-table" command which is conflicting
> >> >with the default formatting.
> >> >
> >> >Any ideas?
> >> >
> >> >Thanks
> >> >Chris
> >>

>

My System SpecsSystem Spec
Old 06-28-2006   #6 (permalink)
Andrew Watt [MVP]


 
 

Re: Scripting bug?

On Wed, 28 Jun 2006 04:59:02 -0700, Aspa
<Aspa@discussions.microsoft.com> wrote:

>
>> (Although the $DCs variable is originally derived from the $Domain)

>
>That's the key, so actually it IS the same :-)


Dennis,

No they're not the same.

Run

$domain.GetType().fullname

and

$DCs.GetType().fullname

and you will see that the types are different.

Andrew Watt MVP
My System SpecsSystem Spec
Old 06-28-2006   #7 (permalink)
Aspa


 
 

Re: Scripting bug?

> Dennis,
> No they're not the same.
> Run
> $domain.GetType().fullname
>
> and
>
> $DCs.GetType().fullname
>
> and you will see that the types are different.
>
> Andrew Watt MVP
>


You're right. Classes are different. spoke before thinking. Only the
namespace is the same
But after trying something else, I found out that all this has nothing to do
with it.
try

PS>gps;gcm

then try

PS>gps;gcm|ft

First works fine, last one doesn't work.

Dennis
My System SpecsSystem Spec
Old 06-28-2006   #8 (permalink)
dreeschkind


 
 

Re: Scripting bug?

I can confirm the bug you are seeing.
I believe the reason is that PowerShell is not able to switch the object
formating within a stream. At least I think I read something like that in the
newsgroup or the powershell blog some weeks ago.

--
greetings
dreeschkind

"Aspa" wrote:

> > Dennis,
> > No they're not the same.
> > Run
> > $domain.GetType().fullname
> >
> > and
> >
> > $DCs.GetType().fullname
> >
> > and you will see that the types are different.
> >
> > Andrew Watt MVP
> >

>
> You're right. Classes are different. spoke before thinking. Only the
> namespace is the same
> But after trying something else, I found out that all this has nothing to do
> with it.
> try
>
> PS>gps;gcm
>
> then try
>
> PS>gps;gcm|ft
>
> First works fine, last one doesn't work.
>
> Dennis

My System SpecsSystem Spec
Old 06-28-2006   #9 (permalink)
/\/\o\/\/ [MVP]


 
 

Re: Scripting bug?

DreeschKind is right,

this is a bug (will not be fixed in V1 I think),
that you can not use the default formatter in a script.

(if the are different formats used), from the commandline this does work.

the workaround is not trowing objects to the pipeline unformatted.

MowPS>function test {
>> ls | fl
>> ls
>> ls | ft
>> }
>>

MowPS>test

now the last line will give an error as the "middle" LS does use the default
formatter.


Greetings /\/\o\/\/



"dreeschkind" wrote:

> I can confirm the bug you are seeing.
> I believe the reason is that PowerShell is not able to switch the object
> formating within a stream. At least I think I read something like that in the
> newsgroup or the powershell blog some weeks ago.
>
> --
> greetings
> dreeschkind
>
> "Aspa" wrote:
>
> > > Dennis,
> > > No they're not the same.
> > > Run
> > > $domain.GetType().fullname
> > >
> > > and
> > >
> > > $DCs.GetType().fullname
> > >
> > > and you will see that the types are different.
> > >
> > > Andrew Watt MVP
> > >

> >
> > You're right. Classes are different. spoke before thinking. Only the
> > namespace is the same
> > But after trying something else, I found out that all this has nothing to do
> > with it.
> > try
> >
> > PS>gps;gcm
> >
> > then try
> >
> > PS>gps;gcm|ft
> >
> > First works fine, last one doesn't work.
> >
> > Dennis

My System SpecsSystem Spec
Old 06-28-2006   #10 (permalink)
Chris Warwick


 
 

Re: Scripting bug?

Thanks for the update - I'll avoid the default formatter in scripts
for the time being!



On Wed, 28 Jun 2006 08:45:02 -0700, /\/\o\/\/ [MVP]
<oMVP@discussions.microsoft.com> wrote:

>DreeschKind is right,
>
>this is a bug (will not be fixed in V1 I think),
>that you can not use the default formatter in a script.
>
>(if the are different formats used), from the commandline this does work.
>
>the workaround is not trowing objects to the pipeline unformatted.
>
>MowPS>function test {
>>> ls | fl
>>> ls
>>> ls | ft
>>> }
>>>

>MowPS>test
>
>now the last line will give an error as the "middle" LS does use the default
>formatter.
>
>
>Greetings /\/\o\/\/
>
>
>
>"dreeschkind" wrote:
>
>> I can confirm the bug you are seeing.
>> I believe the reason is that PowerShell is not able to switch the object
>> formating within a stream. At least I think I read something like that in the
>> newsgroup or the powershell blog some weeks ago.
>>
>> --
>> greetings
>> dreeschkind
>>
>> "Aspa" wrote:
>>
>> > > Dennis,
>> > > No they're not the same.
>> > > Run
>> > > $domain.GetType().fullname
>> > >
>> > > and
>> > >
>> > > $DCs.GetType().fullname
>> > >
>> > > and you will see that the types are different.
>> > >
>> > > Andrew Watt MVP
>> > >
>> >
>> > You're right. Classes are different. spoke before thinking. Only the
>> > namespace is the same
>> > But after trying something else, I found out that all this has nothing to do
>> > with it.
>> > try
>> >
>> > PS>gps;gcm
>> >
>> > then try
>> >
>> > PS>gps;gcm|ft
>> >
>> > First works fine, last one doesn't work.
>> >
>> > Dennis

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Registry scripting VB Script
Re: batch scripting VB Script
Scripting question Vista General
VB scripting help VB Script
UAC and scripting Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46