【发布时间】:2020-05-22 11:22:54
【问题描述】:
我试图创建一个简单的脚本,该脚本将转到服务器并获取文件夹的 acl 详细信息。我测试了命令:
Invoke-command -Computername Servername -ScriptBlock {(Get-Acl "\\Server\Folder\user folders").access | ft- auto}
这工作正常。但是,当我试图将它放入允许我通过变量输入路径的脚本中时,我总是得到:
Cannot validate argument on parameter 'Path'. The argument is null or empty. Supply an argument that is not null or empty and then
try the command again.
+ CategoryInfo : InvalidData: (:) [Get-Acl], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetAclCommand
这是我的脚本:
#get folder permissions from remote computer
$serverName = read-host "Please enter the name of the target server"
$folderPath = "\\server_name\Folder\user folders"
#read-host "Please enter the full path to the target folder"
Invoke-command -ComputerName $serverName -ScriptBlock {(get-acl $folderPath).access | ft -wrap}
这可能很简单,但我会很感激你的帮助。
【问题讨论】:
标签: powershell