Powershell脚本列出所有共享中的文件夹


0

愚蠢的问题,但不确定是否可行。

我有一个托管8个单独共享的文件服务器。我正在寻找一个脚本来提取所有共享的文件夹名称列表(无子文件夹)。

我可以使用Get-ChildItem -path“ \ server1 \ share1 *” | 其中{$ _。PsIsContainer}列出特定共享的文件夹,但是我试图找到一种方法,仅使用服务器路径一次列出所有共享和文件夹。

是唯一为每个共享单独运行脚本的选项吗?

Answers:


1
Get-WmiObject -Query "SELECT Name, Path FROM Win32_Share" | Format-Table Name, Path

0

听起来好像您想要Get-Childitem的-recurse参数,它列出了下面每个文件夹的内容(以及它们的内容),尽管如果有很多文件夹,这可能会变得很笨拙。

另一种选择是使用通配符(*)。

Get-Childitem -path "\server1\*\*"

这将搜索“ \ server1”中的所有文件夹,然后搜索这些文件夹中的所有文件夹,如果您想使其更深入(dir-ception!),则可以添加更多“ *”。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.