通过 powershell 读取 NAS 文件夹

Reading NAS folders via powershell

您好 :) 这是我的问题: 我想看看我的 NAS 有多少个子文件夹。 通过 Google 我发现了以下内容:

Get-ChildItem -Path \<#NASIP#>\ | SELECT Attributes, Name, CreationTime | Format-Table -AutoSize;

我可以扩展这个命令,这样我就知道最后有多少(例如“8”)。 但是现在这个命令没有按预期工作。 如果我使用纯 IP:\\<#NASIP#>\ 会显示以下错误:

Get-ChildItem : The path "\<#NASIP##>\" cannot be found, because it does not exist.

如果我现在指定一个子文件夹,例如图片:\\<#NASIP#>\图片

                Attributes Name           CreationTime
                ---------- ----           ------------
System, Directory, Archive xxxxxx         xxxxxxxxxx 15:26:37
        Directory, Archive xxxxxx         xxxxxxxxxx 20:51:17
        Directory, Archive xxxxxx         xxxxxxxxxx 11:35:26
        Directory, Archive xxxxxx         xxxxxxxxxx 21:19:19

该命令没有任何问题,我得到了正确的所有输出。 有人知道这可能是什么吗?

你好扎拉

找到解决方案。由于NAS不共享文件夹而是共享,所以与Get-ChildItem不兼容。 作为替代方案,我现在通过网络视图来完成。这没有问题。 命令的示例:

net view \$target /all | ?{$_ -match 'platte*'} | %{$_ -match '^(.+?)\s+Platte*'|out-null;$matches[1]}

你好扎拉