为何总是报错?已经获取了要的结果


PowerShell交流中心为何总是报错?已经获取了要的结果
0
humblejohn asked 6 年 ago

下列这是报错,我已经获取了我的结果,但是还是报错

Get-Acl : Cannot validate argument on parameter ‘Path’. The argument is n
or empty. Supply an argument that is not null or empty and then try the
command again.
At D:\bt\get-acl.ps1:10 char:13
+ get-acl $lamp[$i]
+ ~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Get-Acl], ParameterBindin
dationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.
Shell.Commands.GetAclCommand

ls d:\lamp -Recurse | Select-Object fullname -first 10 | out-file c:\lamp.txt
$lamp = get-content c:\lamp.txt
$j=$lamp.count
for ($i=2;$i -le $j;$i++)
{get-acl $lamp[$i] }

 

这时源码,已经获取了我要的结果

Directory: D:\lamp

Path Owner Access
—- —– ——
01 … BUILTIN\Administrators BUILTIN\Administrators…
Kindle Note … BUILTIN\Administrators BUILTIN\Administrators…
MA … NT AUTHORITY\SYSTEM BUILTIN\Administrators…
Mana … BUILTIN\Administrators BUILTIN\Administrators…
PMP … BUILTIN\Administrators BUILTIN\Administrators…
super simple songs(MP3… BUILTIN\Administrators BUILTIN\Administrators…

1 Answers
0
Best Answer
Mooser Lee 管理员 answered 6 年 ago

兄弟,这肯定又是空行的问题。不太确定,你为什么喜欢把对象输出到文本。

dir C:\Windows\ -Recurse | Select -First 10

一行就OK了