![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
| | #9 (permalink) |
| | 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 Specs![]() |
| | #10 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||