我有一个脚本,扫描服务器的驱动器包含共享。 之后,我需要它从已经用相同的脚本创build的模板创build文件屏幕,该部分工作正常。
以下是我如何获得有共享的驱动器列表:
`$drivesContainingShares = @(Get-WmiObject Win32_Share | Select Name,Path,Type | Where-Object { $_.Type -match '0|2147483648' } | Select -ExpandProperty Path | Select -Unique)`
这是$ drivesContainingShares的输出
PS C:\> $drivesContainingShares C:\Windows C:\
我无法运行我的命令为包含共享的每个驱动器创build一个文件屏幕。 我必须在很多服务器上运行这个任何想法?
这里是我现在在哪里:我可以创build一个文件屏幕,如果我手动inputpath在第一行。 但我需要自动化,每个serer将有不同的份额。
$newFileScreen = New-FsrmFileScreen -Path $drivesContainingShares -Template $fileTemplateName $drivesContainingShares | ForEach{$newFileScreen}
我一直在尝试多种不同的方式。我得到像“无法validation参数path”参数的错误。参数为空或空。
好吧,我只是不得不占上风,但我知道了。 我把我的for-each语句改为:
foreach ($_ in $drivesContainingShares) {New-FsrmFileScreen -Path $_ -Template $fileTemplateName}
然后我删除了这些行。
$newFileScreen = New-FsrmFileScreen -Path $drivesContainingShares -Template $fileTemplateName $drivesContainingShares | ForEach{$newFileScreen}
现在我的filescreens被创build!