我正在尝试使用PowerShell中的FileSystemWatcher监控azure文件共享中出现的文件。该脚本在查看机器上的文件夹时工作正常,但当我将其指向已映射到azure File share的映射rive时,它会报告“该目录名称无效”。
New-Object :使用"2“参数调用".ctor”时出现异常:“目录名称无效。”
映射的驱动器将显示在资源管理器中,并且可以访问。FileSystemWatcher可以访问azure资源吗?
发布于 2020-09-29 01:12:48
FileSystemWatcher也可以很好地监控挂载的Azure文件共享。
您只需执行mount the file share correctly并为其分配一个驱动器号。例如,我有一个活动文件共享,在我的机器上挂载为Drive **Z:**。
映射后,设置folder和filter变量:
$folder = 'Z:\' # Or the drive letter you have the share mounted onto
$filter = '*.*'
# Create an instance of the FileSystemWatcher class
$fsw = New-Object IO.FileSystemWatcher $folder, $filter -Property @{IncludeSubdirectories = $false;NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'} script的其余部分可以按原样执行。下面是它看起来的样子:

https://stackoverflow.com/questions/64086784
复制相似问题