Why can't I navigate Active Directory within Powershell?
I have an AD: drive, which should allow me to browse active directory from within Powershell. But when I try to use it, it will not let me navigate beyond the root. From what I have read the given commands should work, but they are failing.
PS AD:\> ls
Name ObjectClass DistinguishedName
---- ----------- -----------------
company domainDNS DC=company,DC=com
Configuration configuration CN=Configuration,DC=company,DC=com
Schema dMD CN=Schema,CN=Configuration,DC=company,DC=com
ForestDnsZones domainDNS DC=ForestDnsZones,DC=company,DC=com
DomainDnsZones domainDNS DC=DomainDnsZones,DC=company,DC=com
PS AD:\> cd schema
Set-Location : Cannot find path 'AD:\schema' because it does not exist.
At line:1 char:3
+ cd <<<< schema
+ CategoryInfo : ObjectNotFound: (AD:\schema:String) [Set-Location], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
PS AD:\> cd Schema
Set-Location : Cannot find path 'AD:\Schema' because it does not exist.
(duplicate of previous error)
PS AD:\> cd company
Set-Location : Cannot find path 'AD:\company' because it does not exist.
(duplicate of previous error)
PS AD:\> ls Schema
Get-ChildItem : Cannot find path '//RootDSE/Schema' because it does not exist.
(duplicate of previous error)
PS AD:\> cd ForestDnsZones
Set-Location : Cannot find path 'AD:\ForestDnsZones' because it does not exist.
(duplicate of previous error)
You need to use the Distinguished name. Try cd dc=company,dc=com
. Note that tab completion works well here. So try cd dc=comp <tab>
. It should expand to the whole DN
That's because you need to use the DistinguishedName, not the Name.
PS AD:\> cd "DC=Company,DC=Com"