我有一个简单的 myscript.ps1
,用于从文件中提取URL,该脚本来自于这个教程:
$input_path = 'd:\myfolder\*'
$output_file = 'd:\extracted_URL_addresses.txt'
$regex = '([a-zA-Z]{3,})://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
select-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file
我以管理员身份运行PowerShell,然后输入:
D:/myscript.ps1
但是对于d:\myfolder
内的大多数路径,我得到了以下信息:
select-string : The file D:\myfolder\templates cannot be read: Access to the path 'D:\myfolder\templates' is denied.
这个文件夹是通过WinSCP从FTP服务器上复制的。我试图进入文件夹属性并取消"只读"框, 然后应用,但每次重新进入属性时,它又变成了"只读"(我不确定这是否与问题有关)。
我使用的操作系统是Windows 10。
D:\myfolder\templates
是一个文件夹,而不是适用于 Select-String 的文件。 - user6811411