Forum Discussion
Dfs Namespace folder properties error using powershell
In lines 376 and 394 you have statements that look like this:
if(get-dfsnroot -path \\$DomainShort\$DFSRootName-DFS | get-dfsnroottarget | where {$_.Targetpath -like "*$Computername*"}) {
Where you have not enclosed the value following -Path in double quotes as you should have. The value should look like this:
# It should look like this:
-path "\\$DomainShort\$DFSRootName-DFS"
# Not what you have, which is this:
-path \\$DomainShort\$DFSRootName-DFS
Given it's a long script, I've only focused on your first error, as there's a good chance the rest are related.
Cheers,
Lain
LainRobertson
Thank you so much for your quick response.
however, I am still getting the same error after adding the double quotes.
get-dfsnroot : Cannot get DFS folder properties on "\\\-DFS"
At C:\install\DFS1.ps1:393 char:8
+ if(get-dfsnroot -path "\\$DomainShort\$DFSRootName-DFS" | get-dfs ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MSFT_DFSNamespace:ROOT\Microsoft\...FT_DFSNamespace) [Get-DfsnRoot], CimException
+ FullyQualifiedErrorId : Windows System Error 87,Get-DfsnRoot
get-dfsnroot : One or more parameter values passed to the method were invalid.
At C:\install\DFS1.ps1:393 char:8
+ if(get-dfsnroot -path "\\$DomainShort\$DFSRootName-DFS" | get-dfs ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (MSFT_DFSNamespace:ROOT\Microsoft\...FT_DFSNamespace) [Get-DfsnRoot], CimException
+ FullyQualifiedErrorId : MI RESULT 4,Get-DfsnRoot
- LainRobertsonDec 04, 2023Silver Contributor
Okay, if you're running the following within both those lines and still getting that error then that means the $DomainShort and $DFSRootName variables are set to $null (or an empty string).
get-dfsnroot -path "\\$DomainShort\$DFSRootName-DFS"As the error clearly states that what you're passing in via the "-path" parameter is a string value of "\\\-DFS".
Cheers,
Lain
- VinodkumarloharDec 04, 2023Copper Contributor
Here "abc" is the user input value which should be store in the $DFSRootName
so after execute the script it will create the path of namespace \\domainName\abc-DFS.
.DESCRIPTION
The script if for: Creating DFS roots in sites and for ABC roots for domain.
Installation Log will be created in C:\Install folderExample usage:
.\DFSroot.ps1 - It will create DFS root for site parsed from server hostname- e.g:
Executed on server: dc.net will create abc-DFS root.\DFSroot.ps1 ABC - It will create DFS root ABC-DFS
- LainRobertsonDec 04, 2023Silver Contributor
Error 87 is LDAP_FILTER_ERROR.
I'm unable to even begin to guess as to why you're receiving that.
But as I say, the bigger initial issue appears to be the string being passed in via "-path", as "\\\-DFS" is never going to work.
Cheers,
Lain
- VinodkumarloharDec 04, 2023Copper Contributoralso I am executing the script using syntax as below
dfs.ps1 abc multipledfs
dfs.ps1 = long script
abc = namespace name
multipledfs