![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | ADO & Powershell It was mentioned to me that Powershell may have issues with ADO but I can't seem to find a reference to back that up. As such, I'm working on the assumption that it will eventually work. I've been trying to execute a simple LDAP query against a backend AD, the goal of which is to simply iterate through the result set and do 'X' task with each of the objects. Here's what's being returned - PS C:\> C:\test.ps1 Exception calling "Execute" with "0" argument(s): "Table does not exist." At C:\test.ps1:11 char:28 + $qRes = $objCommand.Execute( <<<< ) Here's C:\test.ps1 - $objCommand = New-object -comobject "ADODB.Command" $objConnection = New-object -comobject "ADODB.Connection" $objConnection.Provider = "ADsDSOObject;UserID=administrator;Password=password;" $objConnection.Open("Active Directory Provider") $objCommand.ActiveConnection = $objConnection $query = "<LDAP://cubelet/dc=mset,dc=lab>;(objectcategory=user);1.1;subtree" $objCommand.CommandText = $query $qRes = $objCommand.Execute() If would appear the Execute method requires a few args. in Powershell, any pointers? Thanks in advance! -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l |
My System Specs![]() |
| | #2 (permalink) |
| | Re: ADO & Powershell On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote: > I've been trying to >execute a simple LDAP query against a backend AD, the goal of which is >to simply iterate through the result set and do 'X' task with each of >the objects. Try this: $Searcher=New-Object DirectoryServices.DirectorySearcher $Searcher.Filter="(objectcategory=user)" # LDAP of your choice $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} Change the last line to pick out the attributes you're interested in hth Chris |
My System Specs![]() |
| | #3 (permalink) |
| | Re: ADO & Powershell Thanks Chris ... appreciate it, I'll give that a go. And though helpful in this instance, it still leaves the bigger question re: ADO, any further input? -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" > <dwells@mask.msetechnology.com> wrote: > >> I've been trying to >>execute a simple LDAP query against a backend AD, the goal of which is >>to simply iterate through the result set and do 'X' task with each of >>the objects. > > Try this: > > $Searcher=New-Object DirectoryServices.DirectorySearcher > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} > > Change the last line to pick out the attributes you're interested in > > hth > Chris |
My System Specs![]() |
| | #4 (permalink) |
| | Re: ADO & Powershell This works for me : PoSH>$objCommand = New-object -comobject "ADODB.Command" PoSH>$objConnection = New-object -comobject "ADODB.Connection" PoSH>$objConnection.Provider = "ADsDSOObject" PoSH>$objConnection.Open("Active Directory Provider") PoSH>$objCommand.ActiveConnection = $objConnection PoSH> PoSH>$query = "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" PoSH>$objCommand.CommandText = $query PoSH>$qRes = $objCommand.Execute() PoSH>$qres Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, IConvertType...} AbsolutePosition : 1 ActiveConnection : ADODB.ConnectionClass BOF : False Bookmark : 0 CacheSize : 1 CursorType : adOpenStatic EOF : False Fields : {cn, adspath} LockType : adLockReadOnly MaxRecords : 0 RecordCount : 21 Source : <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree AbsolutePage : 1 EditMode : adEditNone Filter : 0 PageCount : 3 PageSize : 10 Sort : Status : 0 State : 1 CursorLocation : adUseServer MarshalOptions : adMarshalAll DataSource : ADODB.RecordsetClass ActiveCommand : ADODB.CommandClass StayInSync : True DataMember : Index : PoSH>$qres.fields Status : 0 ActualSize : 26 Attributes : 32 DataFormat : DefinedSize : 256 Name : cn NumericScale : 255 OriginalValue : Precision : 255 Properties : {} Type : adVarWChar UnderlyingValue : Value : Administrator Status : 0 ActualSize : 114 Attributes : 32 DataFormat : DefinedSize : 256 Name : adspath NumericScale : 255 OriginalValue : Precision : 255 Properties : {} Type : adVarWChar UnderlyingValue : Value : LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local Greetings /\/\o\/\/ for more examples using .NET see : http://mow001.blogspot.com/2006/08/p...ry-part-8.html "Dean Wells [MVP]" wrote: > Thanks Chris ... appreciate it, I'll give that a go. > > And though helpful in this instance, it still leaves the bigger question > re: ADO, any further input? > > -- > Dean Wells [MVP / Directory Services] > MSEtechnology > [[ Please respond to the Newsgroup only regarding posts ]] > R e m o v e t h e m a s k t o s e n d e m a i l > > "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message > news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... > > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" > > <dwells@mask.msetechnology.com> wrote: > > > >> I've been trying to > >>execute a simple LDAP query against a backend AD, the goal of which is > >>to simply iterate through the result set and do 'X' task with each of > >>the objects. > > > > Try this: > > > > $Searcher=New-Object DirectoryServices.DirectorySearcher > > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice > > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} > > > > Change the last line to pick out the attributes you're interested in > > > > hth > > Chris > > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: ADO & Powershell Heh, still doesn't work for me as is ... it seems supplying the creds. causes the failure - [FAILS] $objConnection.Provider = "ADsDSOObject;UserID=administrator;Password=password;" [SUCCEEDS] $objConnection.Provider = "ADsDSOObject" .... sadly, it doesn't entriely resolve the issue since I do on occasion need to provide the credentials. -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... > This works for me : > > PoSH>$objCommand = New-object -comobject "ADODB.Command" > PoSH>$objConnection = New-object -comobject "ADODB.Connection" > PoSH>$objConnection.Provider = "ADsDSOObject" > PoSH>$objConnection.Open("Active Directory Provider") > PoSH>$objCommand.ActiveConnection = $objConnection > PoSH> > PoSH>$query = > "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" > PoSH>$objCommand.CommandText = $query > PoSH>$qRes = $objCommand.Execute() > PoSH>$qres > > > Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, > IConvertType...} > AbsolutePosition : 1 > ActiveConnection : ADODB.ConnectionClass > BOF : False > Bookmark : 0 > CacheSize : 1 > CursorType : adOpenStatic > EOF : False > Fields : {cn, adspath} > LockType : adLockReadOnly > MaxRecords : 0 > RecordCount : 21 > Source : > <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree > AbsolutePage : 1 > EditMode : adEditNone > Filter : 0 > PageCount : 3 > PageSize : 10 > Sort : > Status : 0 > State : 1 > CursorLocation : adUseServer > MarshalOptions : adMarshalAll > DataSource : ADODB.RecordsetClass > ActiveCommand : ADODB.CommandClass > StayInSync : True > DataMember : > Index : > > > > PoSH>$qres.fields > > > Status : 0 > ActualSize : 26 > Attributes : 32 > DataFormat : > DefinedSize : 256 > Name : cn > NumericScale : 255 > OriginalValue : > Precision : 255 > Properties : {} > Type : adVarWChar > UnderlyingValue : > Value : Administrator > > Status : 0 > ActualSize : 114 > Attributes : 32 > DataFormat : > DefinedSize : 256 > Name : adspath > NumericScale : 255 > OriginalValue : > Precision : 255 > Properties : {} > Type : adVarWChar > UnderlyingValue : > Value : > LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local > > Greetings /\/\o\/\/ > for more examples using .NET see : > > http://mow001.blogspot.com/2006/08/p...ry-part-8.html > > "Dean Wells [MVP]" wrote: > >> Thanks Chris ... appreciate it, I'll give that a go. >> >> And though helpful in this instance, it still leaves the bigger >> question >> re: ADO, any further input? >> >> -- >> Dean Wells [MVP / Directory Services] >> MSEtechnology >> [[ Please respond to the Newsgroup only regarding posts ]] >> R e m o v e t h e m a s k t o s e n d e m a i l >> >> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message >> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... >> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" >> > <dwells@mask.msetechnology.com> wrote: >> > >> >> I've been trying to >> >>execute a simple LDAP query against a backend AD, the goal of which >> >>is >> >>to simply iterate through the result set and do 'X' task with each >> >>of >> >>the objects. >> > >> > Try this: >> > >> > $Searcher=New-Object DirectoryServices.DirectorySearcher >> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice >> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} >> > >> > Change the last line to pick out the attributes you're interested >> > in >> > >> > hth >> > Chris >> >> >> |
My System Specs![]() |
| | #6 (permalink) |
| | Re: ADO & Powershell By any chance, does the password include any of the following characters: `(backtick) or one of {$( This is grabbing at straws. : | "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message news:uL6LCtTwGHA.4868@TK2MSFTNGP02.phx.gbl... > Heh, still doesn't work for me as is ... it seems supplying the creds. > causes the failure - > > [FAILS] > $objConnection.Provider = > "ADsDSOObject;UserID=administrator;Password=password;" > > [SUCCEEDS] > $objConnection.Provider = "ADsDSOObject" > > ... sadly, it doesn't entriely resolve the issue since I do on occasion > need to provide the credentials. > > -- > Dean Wells [MVP / Directory Services] > MSEtechnology > [[ Please respond to the Newsgroup only regarding posts ]] > R e m o v e t h e m a s k t o s e n d e m a i l > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... >> This works for me : >> >> PoSH>$objCommand = New-object -comobject "ADODB.Command" >> PoSH>$objConnection = New-object -comobject "ADODB.Connection" >> PoSH>$objConnection.Provider = "ADsDSOObject" >> PoSH>$objConnection.Open("Active Directory Provider") >> PoSH>$objCommand.ActiveConnection = $objConnection >> PoSH> >> PoSH>$query = >> "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" >> PoSH>$objCommand.CommandText = $query >> PoSH>$qRes = $objCommand.Execute() >> PoSH>$qres >> >> >> Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, >> IConvertType...} >> AbsolutePosition : 1 >> ActiveConnection : ADODB.ConnectionClass >> BOF : False >> Bookmark : 0 >> CacheSize : 1 >> CursorType : adOpenStatic >> EOF : False >> Fields : {cn, adspath} >> LockType : adLockReadOnly >> MaxRecords : 0 >> RecordCount : 21 >> Source : >> <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree >> AbsolutePage : 1 >> EditMode : adEditNone >> Filter : 0 >> PageCount : 3 >> PageSize : 10 >> Sort : >> Status : 0 >> State : 1 >> CursorLocation : adUseServer >> MarshalOptions : adMarshalAll >> DataSource : ADODB.RecordsetClass >> ActiveCommand : ADODB.CommandClass >> StayInSync : True >> DataMember : >> Index : >> >> >> >> PoSH>$qres.fields >> >> >> Status : 0 >> ActualSize : 26 >> Attributes : 32 >> DataFormat : >> DefinedSize : 256 >> Name : cn >> NumericScale : 255 >> OriginalValue : >> Precision : 255 >> Properties : {} >> Type : adVarWChar >> UnderlyingValue : >> Value : Administrator >> >> Status : 0 >> ActualSize : 114 >> Attributes : 32 >> DataFormat : >> DefinedSize : 256 >> Name : adspath >> NumericScale : 255 >> OriginalValue : >> Precision : 255 >> Properties : {} >> Type : adVarWChar >> UnderlyingValue : >> Value : >> LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local >> >> Greetings /\/\o\/\/ >> for more examples using .NET see : >> >> http://mow001.blogspot.com/2006/08/p...ry-part-8.html >> >> "Dean Wells [MVP]" wrote: >> >>> Thanks Chris ... appreciate it, I'll give that a go. >>> >>> And though helpful in this instance, it still leaves the bigger question >>> re: ADO, any further input? >>> >>> -- >>> Dean Wells [MVP / Directory Services] >>> MSEtechnology >>> [[ Please respond to the Newsgroup only regarding posts ]] >>> R e m o v e t h e m a s k t o s e n d e m a i l >>> >>> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message >>> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... >>> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" >>> > <dwells@mask.msetechnology.com> wrote: >>> > >>> >> I've been trying to >>> >>execute a simple LDAP query against a backend AD, the goal of which is >>> >>to simply iterate through the result set and do 'X' task with each of >>> >>the objects. >>> > >>> > Try this: >>> > >>> > $Searcher=New-Object DirectoryServices.DirectorySearcher >>> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice >>> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} >>> > >>> > Change the last line to pick out the attributes you're interested in >>> > >>> > hth >>> > Chris >>> >>> >>> > > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: ADO & Powershell How do you access a specific Field Value. Example in VBS: rs.Fields("Name").Value In POSH: $rs.Fields("Name").Value POSH failes with Method Error "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... > This works for me : > > PoSH>$objCommand = New-object -comobject "ADODB.Command" > PoSH>$objConnection = New-object -comobject "ADODB.Connection" > PoSH>$objConnection.Provider = "ADsDSOObject" > PoSH>$objConnection.Open("Active Directory Provider") > PoSH>$objCommand.ActiveConnection = $objConnection > PoSH> > PoSH>$query = > "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" > PoSH>$objCommand.CommandText = $query > PoSH>$qRes = $objCommand.Execute() > PoSH>$qres > > > Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, > IConvertType...} > AbsolutePosition : 1 > ActiveConnection : ADODB.ConnectionClass > BOF : False > Bookmark : 0 > CacheSize : 1 > CursorType : adOpenStatic > EOF : False > Fields : {cn, adspath} > LockType : adLockReadOnly > MaxRecords : 0 > RecordCount : 21 > Source : > <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree > AbsolutePage : 1 > EditMode : adEditNone > Filter : 0 > PageCount : 3 > PageSize : 10 > Sort : > Status : 0 > State : 1 > CursorLocation : adUseServer > MarshalOptions : adMarshalAll > DataSource : ADODB.RecordsetClass > ActiveCommand : ADODB.CommandClass > StayInSync : True > DataMember : > Index : > > > > PoSH>$qres.fields > > > Status : 0 > ActualSize : 26 > Attributes : 32 > DataFormat : > DefinedSize : 256 > Name : cn > NumericScale : 255 > OriginalValue : > Precision : 255 > Properties : {} > Type : adVarWChar > UnderlyingValue : > Value : Administrator > > Status : 0 > ActualSize : 114 > Attributes : 32 > DataFormat : > DefinedSize : 256 > Name : adspath > NumericScale : 255 > OriginalValue : > Precision : 255 > Properties : {} > Type : adVarWChar > UnderlyingValue : > Value : > LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local > > Greetings /\/\o\/\/ > for more examples using .NET see : > > http://mow001.blogspot.com/2006/08/p...ry-part-8.html > > "Dean Wells [MVP]" wrote: > >> Thanks Chris ... appreciate it, I'll give that a go. >> >> And though helpful in this instance, it still leaves the bigger question >> re: ADO, any further input? >> >> -- >> Dean Wells [MVP / Directory Services] >> MSEtechnology >> [[ Please respond to the Newsgroup only regarding posts ]] >> R e m o v e t h e m a s k t o s e n d e m a i l >> >> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message >> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... >> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" >> > <dwells@mask.msetechnology.com> wrote: >> > >> >> I've been trying to >> >>execute a simple LDAP query against a backend AD, the goal of which is >> >>to simply iterate through the result set and do 'X' task with each of >> >>the objects. >> > >> > Try this: >> > >> > $Searcher=New-Object DirectoryServices.DirectorySearcher >> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice >> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} >> > >> > Change the last line to pick out the attributes you're interested in >> > >> > hth >> > Chris >> >> >> |
My System Specs![]() |
| | #8 (permalink) |
| | Re: ADO & Powershell Sadly no, the password is the literal I posted earlier - "password". -- Dean Wells [MVP / Directory Services] MSEtechnology [[ Please respond to the Newsgroup only regarding posts ]] R e m o v e t h e m a s k t o s e n d e m a i l "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message news:%23hpHOOUwGHA.324@TK2MSFTNGP06.phx.gbl... > By any chance, does the password include any of the following > characters: > `(backtick) > or one of > {$( > This is grabbing at straws. : | > > > "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message > news:uL6LCtTwGHA.4868@TK2MSFTNGP02.phx.gbl... >> Heh, still doesn't work for me as is ... it seems supplying the >> creds. causes the failure - >> >> [FAILS] >> $objConnection.Provider = >> "ADsDSOObject;UserID=administrator;Password=password;" >> >> [SUCCEEDS] >> $objConnection.Provider = "ADsDSOObject" >> >> ... sadly, it doesn't entriely resolve the issue since I do on >> occasion need to provide the credentials. >> >> -- >> Dean Wells [MVP / Directory Services] >> MSEtechnology >> [[ Please respond to the Newsgroup only regarding posts ]] >> R e m o v e t h e m a s k t o s e n d e m a i l >> >> "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message >> news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... >>> This works for me : >>> >>> PoSH>$objCommand = New-object -comobject "ADODB.Command" >>> PoSH>$objConnection = New-object -comobject "ADODB.Connection" >>> PoSH>$objConnection.Provider = "ADsDSOObject" >>> PoSH>$objConnection.Open("Active Directory Provider") >>> PoSH>$objCommand.ActiveConnection = $objConnection >>> PoSH> >>> PoSH>$query = >>> "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" >>> PoSH>$objCommand.CommandText = $query >>> PoSH>$qRes = $objCommand.Execute() >>> PoSH>$qres >>> >>> >>> Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, >>> IConvertType...} >>> AbsolutePosition : 1 >>> ActiveConnection : ADODB.ConnectionClass >>> BOF : False >>> Bookmark : 0 >>> CacheSize : 1 >>> CursorType : adOpenStatic >>> EOF : False >>> Fields : {cn, adspath} >>> LockType : adLockReadOnly >>> MaxRecords : 0 >>> RecordCount : 21 >>> Source : >>> <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree >>> AbsolutePage : 1 >>> EditMode : adEditNone >>> Filter : 0 >>> PageCount : 3 >>> PageSize : 10 >>> Sort : >>> Status : 0 >>> State : 1 >>> CursorLocation : adUseServer >>> MarshalOptions : adMarshalAll >>> DataSource : ADODB.RecordsetClass >>> ActiveCommand : ADODB.CommandClass >>> StayInSync : True >>> DataMember : >>> Index : >>> >>> >>> >>> PoSH>$qres.fields >>> >>> >>> Status : 0 >>> ActualSize : 26 >>> Attributes : 32 >>> DataFormat : >>> DefinedSize : 256 >>> Name : cn >>> NumericScale : 255 >>> OriginalValue : >>> Precision : 255 >>> Properties : {} >>> Type : adVarWChar >>> UnderlyingValue : >>> Value : Administrator >>> >>> Status : 0 >>> ActualSize : 114 >>> Attributes : 32 >>> DataFormat : >>> DefinedSize : 256 >>> Name : adspath >>> NumericScale : 255 >>> OriginalValue : >>> Precision : 255 >>> Properties : {} >>> Type : adVarWChar >>> UnderlyingValue : >>> Value : >>> LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local >>> >>> Greetings /\/\o\/\/ >>> for more examples using .NET see : >>> >>> http://mow001.blogspot.com/2006/08/p...ry-part-8.html >>> >>> "Dean Wells [MVP]" wrote: >>> >>>> Thanks Chris ... appreciate it, I'll give that a go. >>>> >>>> And though helpful in this instance, it still leaves the bigger >>>> question >>>> re: ADO, any further input? >>>> >>>> -- >>>> Dean Wells [MVP / Directory Services] >>>> MSEtechnology >>>> [[ Please respond to the Newsgroup only regarding posts ]] >>>> R e m o v e t h e m a s k t o s e n d e m a i l >>>> >>>> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message >>>> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... >>>> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" >>>> > <dwells@mask.msetechnology.com> wrote: >>>> > >>>> >> I've been trying to >>>> >>execute a simple LDAP query against a backend AD, the goal of >>>> >>which is >>>> >>to simply iterate through the result set and do 'X' task with >>>> >>each of >>>> >>the objects. >>>> > >>>> > Try this: >>>> > >>>> > $Searcher=New-Object DirectoryServices.DirectorySearcher >>>> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice >>>> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} >>>> > >>>> > Change the last line to pick out the attributes you're interested >>>> > in >>>> > >>>> > hth >>>> > Chris >>>> >>>> >>>> >> >> > > |
My System Specs![]() |
| | #9 (permalink) |
| | Re: ADO & Powershell I'm able to make this work reliably from a session on the server, using alternate credentials, by doing this. Note that instead of tacking the credentials onto the Provider, I modify the ConnectionString property after setting the Provider. $objConnection.Provider = "ADsDSOObject" $objConnection.ConnectionString = $objConnection.ConnectionString + ";" + "UserID=admin2;Password=!Pa55word" $objConnection.Open("Active Directory Provider") "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message news:OM$TR8UwGHA.1284@TK2MSFTNGP05.phx.gbl... > Sadly no, the password is the literal I posted earlier - "password". > > -- > Dean Wells [MVP / Directory Services] > MSEtechnology > [[ Please respond to the Newsgroup only regarding posts ]] > R e m o v e t h e m a s k t o s e n d e m a i l > > "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message > news:%23hpHOOUwGHA.324@TK2MSFTNGP06.phx.gbl... >> By any chance, does the password include any of the following characters: >> `(backtick) >> or one of >> {$( >> This is grabbing at straws. : | >> >> >> "Dean Wells [MVP]" <dwells@mask.msetechnology.com> wrote in message >> news:uL6LCtTwGHA.4868@TK2MSFTNGP02.phx.gbl... >>> Heh, still doesn't work for me as is ... it seems supplying the creds. >>> causes the failure - >>> >>> [FAILS] >>> $objConnection.Provider = >>> "ADsDSOObject;UserID=administrator;Password=password;" >>> >>> [SUCCEEDS] >>> $objConnection.Provider = "ADsDSOObject" >>> >>> ... sadly, it doesn't entriely resolve the issue since I do on occasion >>> need to provide the credentials. >>> >>> -- >>> Dean Wells [MVP / Directory Services] >>> MSEtechnology >>> [[ Please respond to the Newsgroup only regarding posts ]] >>> R e m o v e t h e m a s k t o s e n d e m a i l >>> >>> "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message >>> news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... >>>> This works for me : >>>> >>>> PoSH>$objCommand = New-object -comobject "ADODB.Command" >>>> PoSH>$objConnection = New-object -comobject "ADODB.Connection" >>>> PoSH>$objConnection.Provider = "ADsDSOObject" >>>> PoSH>$objConnection.Open("Active Directory Provider") >>>> PoSH>$objCommand.ActiveConnection = $objConnection >>>> PoSH> >>>> PoSH>$query = >>>> "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" >>>> PoSH>$objCommand.CommandText = $query >>>> PoSH>$qRes = $objCommand.Execute() >>>> PoSH>$qres >>>> >>>> >>>> Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, >>>> IConvertType...} >>>> AbsolutePosition : 1 >>>> ActiveConnection : ADODB.ConnectionClass >>>> BOF : False >>>> Bookmark : 0 >>>> CacheSize : 1 >>>> CursorType : adOpenStatic >>>> EOF : False >>>> Fields : {cn, adspath} >>>> LockType : adLockReadOnly >>>> MaxRecords : 0 >>>> RecordCount : 21 >>>> Source : >>>> <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree >>>> AbsolutePage : 1 >>>> EditMode : adEditNone >>>> Filter : 0 >>>> PageCount : 3 >>>> PageSize : 10 >>>> Sort : >>>> Status : 0 >>>> State : 1 >>>> CursorLocation : adUseServer >>>> MarshalOptions : adMarshalAll >>>> DataSource : ADODB.RecordsetClass >>>> ActiveCommand : ADODB.CommandClass >>>> StayInSync : True >>>> DataMember : >>>> Index : >>>> >>>> >>>> >>>> PoSH>$qres.fields >>>> >>>> >>>> Status : 0 >>>> ActualSize : 26 >>>> Attributes : 32 >>>> DataFormat : >>>> DefinedSize : 256 >>>> Name : cn >>>> NumericScale : 255 >>>> OriginalValue : >>>> Precision : 255 >>>> Properties : {} >>>> Type : adVarWChar >>>> UnderlyingValue : >>>> Value : Administrator >>>> >>>> Status : 0 >>>> ActualSize : 114 >>>> Attributes : 32 >>>> DataFormat : >>>> DefinedSize : 256 >>>> Name : adspath >>>> NumericScale : 255 >>>> OriginalValue : >>>> Precision : 255 >>>> Properties : {} >>>> Type : adVarWChar >>>> UnderlyingValue : >>>> Value : >>>> LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local >>>> >>>> Greetings /\/\o\/\/ >>>> for more examples using .NET see : >>>> >>>> http://mow001.blogspot.com/2006/08/p...ry-part-8.html >>>> >>>> "Dean Wells [MVP]" wrote: >>>> >>>>> Thanks Chris ... appreciate it, I'll give that a go. >>>>> >>>>> And though helpful in this instance, it still leaves the bigger >>>>> question >>>>> re: ADO, any further input? >>>>> >>>>> -- >>>>> Dean Wells [MVP / Directory Services] >>>>> MSEtechnology >>>>> [[ Please respond to the Newsgroup only regarding posts ]] >>>>> R e m o v e t h e m a s k t o s e n d e m a i l >>>>> >>>>> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message >>>>> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... >>>>> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" >>>>> > <dwells@mask.msetechnology.com> wrote: >>>>> > >>>>> >> I've been trying to >>>>> >>execute a simple LDAP query against a backend AD, the goal of which >>>>> >>is >>>>> >>to simply iterate through the result set and do 'X' task with each >>>>> >>of >>>>> >>the objects. >>>>> > >>>>> > Try this: >>>>> > >>>>> > $Searcher=New-Object DirectoryServices.DirectorySearcher >>>>> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice >>>>> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} >>>>> > >>>>> > Change the last line to pick out the attributes you're interested in >>>>> > >>>>> > hth >>>>> > Chris >>>>> >>>>> >>>>> >>> >>> >> >> > > |
My System Specs![]() |
| | #10 (permalink) |
| | Re: ADO & Powershell $qres.fields.item('cn').name cn $qres.fields.item('cn').value Administrator gr /\/\o\/\/ "Brandon Shell" wrote: > How do you access a specific Field Value. > > Example in VBS: > rs.Fields("Name").Value > > In POSH: > $rs.Fields("Name").Value > > POSH failes with Method Error > > > "/\/\o\/\/ [MVP]" <oMVP@discussions.microsoft.com> wrote in message > news:1573FDBD-E45B-4F87-B22B-8897F1A184F2@microsoft.com... > > This works for me : > > > > PoSH>$objCommand = New-object -comobject "ADODB.Command" > > PoSH>$objConnection = New-object -comobject "ADODB.Connection" > > PoSH>$objConnection.Provider = "ADsDSOObject" > > PoSH>$objConnection.Open("Active Directory Provider") > > PoSH>$objCommand.ActiveConnection = $objConnection > > PoSH> > > PoSH>$query = > > "<LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree" > > PoSH>$objCommand.CommandText = $query > > PoSH>$qRes = $objCommand.Execute() > > PoSH>$qres > > > > > > Properties : {IAccessor, IColumnsInfo, IColumnsInfo2, > > IConvertType...} > > AbsolutePosition : 1 > > ActiveConnection : ADODB.ConnectionClass > > BOF : False > > Bookmark : 0 > > CacheSize : 1 > > CursorType : adOpenStatic > > EOF : False > > Fields : {cn, adspath} > > LockType : adLockReadOnly > > MaxRecords : 0 > > RecordCount : 21 > > Source : > > <LDAP://mowdc001/dc=mow,dc=local>;(objectcategory=user);cn,adspath;subtree > > AbsolutePage : 1 > > EditMode : adEditNone > > Filter : 0 > > PageCount : 3 > > PageSize : 10 > > Sort : > > Status : 0 > > State : 1 > > CursorLocation : adUseServer > > MarshalOptions : adMarshalAll > > DataSource : ADODB.RecordsetClass > > ActiveCommand : ADODB.CommandClass > > StayInSync : True > > DataMember : > > Index : > > > > > > > > PoSH>$qres.fields > > > > > > Status : 0 > > ActualSize : 26 > > Attributes : 32 > > DataFormat : > > DefinedSize : 256 > > Name : cn > > NumericScale : 255 > > OriginalValue : > > Precision : 255 > > Properties : {} > > Type : adVarWChar > > UnderlyingValue : > > Value : Administrator > > > > Status : 0 > > ActualSize : 114 > > Attributes : 32 > > DataFormat : > > DefinedSize : 256 > > Name : adspath > > NumericScale : 255 > > OriginalValue : > > Precision : 255 > > Properties : {} > > Type : adVarWChar > > UnderlyingValue : > > Value : > > LDAP://mowdc001/CN=Administrator,CN=Users,DC=mow,DC=local > > > > Greetings /\/\o\/\/ > > for more examples using .NET see : > > > > http://mow001.blogspot.com/2006/08/p...ry-part-8.html > > > > "Dean Wells [MVP]" wrote: > > > >> Thanks Chris ... appreciate it, I'll give that a go. > >> > >> And though helpful in this instance, it still leaves the bigger question > >> re: ADO, any further input? > >> > >> -- > >> Dean Wells [MVP / Directory Services] > >> MSEtechnology > >> [[ Please respond to the Newsgroup only regarding posts ]] > >> R e m o v e t h e m a s k t o s e n d e m a i l > >> > >> "Chris Warwick" <news@remove.this.bit.nuney.com> wrote in message > >> news:m074e2lu2l2lvtu3ggkml94m9m0s5p1dv4@4ax.com... > >> > On Tue, 15 Aug 2006 14:59:06 -0400, "Dean Wells [MVP]" > >> > <dwells@mask.msetechnology.com> wrote: > >> > > >> >> I've been trying to > >> >>execute a simple LDAP query against a backend AD, the goal of which is > >> >>to simply iterate through the result set and do 'X' task with each of > >> >>the objects. > >> > > >> > Try this: > >> > > >> > $Searcher=New-Object DirectoryServices.DirectorySearcher > >> > $Searcher.Filter="(objectcategory=user)" # LDAP of your choice > >> > $Searcher.FindAll()|%{$_.GetDirectoryEntry().DistinguishedName} > >> > > >> > Change the last line to pick out the attributes you're interested in > >> > > >> > hth > >> > Chris > >> > >> > >> > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |