0

My Environment: Windows Server 2012, PowerShell 4.0

According to MSDN documentation, one should be able to mount 'active directory' or 'active directory lightweight directory services' using new-psdrive Cmdlet.

Excerpt from: http://technet.microsoft.com/en-us/library/hh852274(v=wps.620).aspx

You can use the Active Directory module provider to map Active Directory domains, AD LDS instances, and Active Directory Database Mounting Tool instances to specific provider drives. When the Active Directory module is first loaded, a default Active Directory drive (AD:) is mounted. To connect to that drive, run the cd AD: command. To connect a new provider drive to an Active Directory domain, an AD LDS server, or an Active Directory Database Mounting Tool instance, use the following cmdlet:

New-PSDrive **–Server <server or domain name (NetBIOS/FQDN)[:port number]>**  -Name <name of the drive> -PSProvider ActiveDirectory -Root "<DN of the partition/NC>" -Credential <domain name>\<username> 

However the 'server' option is not available in new-psdrive Cmdlet. I am getting 'A parameter cannot be found that matches parameter name 'server'. And I don't see any mention of server property in the help as well: http://technet.microsoft.com/en-US/library/hh849829(v=wps.630).aspx

can anyone please let me know what I am missing here?

PS C:\> Import-Module activedirectory
PS C:\> cd ad:
PS AD:\> New-PSDrive -Name z -PSProvider activedreictory -root "C=MyAdLDSInstance,DC=COM" -server "myserver:50000"
New-PSDrive : A parameter cannot be found that matches parameter name 'server'.
At line:1 char:82
+ ... stance,DC=COM" -server "myserver:50000"
+                    ~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-PSDrive], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.NewPSDriveCommand

PS AD:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      4.0
WSManStackVersion              3.0
SerializationVersion           1.1.0.1
CLRVersion                     4.0.30319.18449
BuildVersion                   6.3.9600.16406
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0}
PSRemotingProtocolVersion      2.2


PS AD:\>
Dreamer
  • 3,371
  • 2
  • 34
  • 50

1 Answers1

1
New-PSDrive -Name z -PSProvider activedreictory -root "C=MyAdLDSInstance,DC=COM" -server "myserver:50000"

You've misspelled ActiveDirectory. The available parameters are dependent upon the PSProvider specified, and activedreictory isn't a valid PSProvider at all.

alroc
  • 27,574
  • 6
  • 51
  • 97
  • wow - that's it :). I was concentrating more on 'error' message - as I thought the binding of the parameters happen first, and assumed it cant bind to 'server' parameter. I don't know that parameters can be 'dynamically' added to 'PowerSehll' based on provider (here: as you pointed out 'Active Directory'). Btw, do you have any reference on how to add the 'dynamic' properties based on provider? just curious - as I don't need that now. Am unblocked :) – Dreamer Apr 29 '14 at 14:49
  • I don't know how/when it's doing the parameter binding as I haven't had a need to dive that deep into PS internals. I do know that newer versions do some interesting voodoo though. – alroc Apr 29 '14 at 15:04
  • 1
    In the cases like that it's other way around: psprovider defines dynamic parameters for cmdlets. More on that can be found here: http://www.beefycode.com/post/Creating-a-PowerShell-Provider-pt-2-Initializing-the-Drive.aspx – BartekB Apr 29 '14 at 18:15