I'm trying to write a powershell script to grab the Path and TargetPath of our DFS shsares. We have several DFS Folders with Disabled Targets so I only want to list the online targets. We have some folders that are throwing an error that it doesn't contain the Method Where.
Get-DfsnFolderTarget \DOMAINprojproject1
Path TargetPath State ReferralPriorityClass ReferralPriorityRank
---- ---------- ----- --------------------- --------------------
\DOMAINprojproject1 \server1.domainproject1 Online sitecost-normal 0
Get-DfsnFolderTarget \DOMAINprojproject2
Path TargetPath State ReferralPriorityClass ReferralPriorityRank
---- ---------- ----- --------------------- --------------------
\DOMAINprojproject2 \server1.domainproject2 Offline sitecost-normal 0
\DOMAINprojproject2 \server2.domainproject2 Offline sitecost-normal 0
\DOMAINprojproject2 \server3.domainProjectsproject2 Online sitecost-normal 0
When I run:
(Get-DfsnFolderTarget \DOMAINprojproject1).Where({$_.State -eq 'Online'}) | Select Path,TargetPath,State
I get:
Method invocation failed because [Microsoft.Management.Infrastructure.CimInstance] does not contain a method named
'Where'.
At line:1 char:1
+ (Get-DfsnFolderTarget \DOMAINprojproject1).Where({$_.State -eq 'Online ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Where:String) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
When I run:
(Get-DfsnFolderTarget \DOMAINprojproject2).Where({$_.State -eq 'Online'}) | Select Path,TargetPath,State
I get:
Path TargetPath State
---- ---------- -----
\DOMAINprojproject2 \server3.domainProjectsproject2 Online
As you can see Project2 is returning exactly what I would expect to see however Project 1 just throws an error.
question from:
https://stackoverflow.com/questions/65831892/powershell-dfs-target-listing 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…