Answered by:
Error when connecting to Domain with New-PSDrive Paramter -Server not found

Question
-
I am trying to add to my script a connector to connect to another Domain. I keep getting the below error when trying to connect.
New-PSDrive : A parameter cannot be found that matches parameter name 'Server'.
I am using the below.
if (-not(Get-PSDrive DomainB)) { New-PSDrive ` –Name DomainB ` –PSProvider ActiveDirectory ` –Server "DC.DomainB.local" ` –Credential (Get-Credential ‘DOMAINB\Test’) ` –Root ‘//RootDSE/’ ` -Scope Global }Else{ "Drive already exists" }
I want the script to then Set-Location so it can run the commands prompted in the new Domain. However i keep getting the error. Google has found little, has this been removed from PS. Or can someone advise a better way?
Thanks in advance all.
Wednesday, June 17, 2020 11:25 AM
Answers
-
I figured it out in the end its simple.
Its connecting to AD but you need the AD Module loaded and running in effect. So i added Import-Module ActiveDirectory to my script and it works fine now.
- Marked as answer by AutoAdmin Monday, June 22, 2020 8:50 AM
Monday, June 22, 2020 8:49 AM
All replies
-
The error is correct. The parameter doesn't exist and never has.
In the future try looking up the command in the documentation.
\_(ツ)_/
- Proposed as answer by Yang YoungMicrosoft contingent staff Monday, June 22, 2020 1:32 AM
- Unproposed as answer by AutoAdmin Monday, June 22, 2020 8:28 AM
Thursday, June 18, 2020 8:33 PM -
Plenty of reference to its use online. Also tried the suggestions on a thread here on it
https://social.technet.microsoft.com/Forums/en-US/cc3e0faf-3fe8-46a2-85fc-03606f9be0f1/server-parameter-not-found-in-newpsdrive?forum=winserverpowershell
So it clearly exists and checking has shown uses. Actually the command is working when done in Visiual Studio Code move to run in PS and it fails.
ThanksMonday, June 22, 2020 8:28 AM -
I figured it out in the end its simple.
Its connecting to AD but you need the AD Module loaded and running in effect. So i added Import-Module ActiveDirectory to my script and it works fine now.
- Marked as answer by AutoAdmin Monday, June 22, 2020 8:50 AM
Monday, June 22, 2020 8:49 AM