Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带通配符的PowerShell测试路径UNC_Powershell_Wildcard_Unc - Fatal编程技术网

带通配符的PowerShell测试路径UNC

带通配符的PowerShell测试路径UNC,powershell,wildcard,unc,Powershell,Wildcard,Unc,我正在尝试测试UNC路径是否存在,但到目前为止,所有尝试都失败了。 此文件夹示例存在,并返回true: 我想确认存在具有类似名称的所有文件夹,例如: 我在以下示例中尝试过使用通配符: test-path "\\Server\Path*" resolve-path "\\Server\Path*" [System.IO.Directory]::Exists('\\Server\Path*'); Test-Path $('filesystem::\\Server\Path*') …以及\“'*组合

我正在尝试测试UNC路径是否存在,但到目前为止,所有尝试都失败了。 此文件夹示例存在,并返回true:

我想确认存在具有类似名称的所有文件夹,例如:

我在以下示例中尝试过使用通配符:

test-path "\\Server\Path*"
resolve-path "\\Server\Path*"
[System.IO.Directory]::Exists('\\Server\Path*');
Test-Path $('filesystem::\\Server\Path*')
…以及\“'*组合的许多排列。
但是,在使用通配符时,我尝试过的任何操作都不会为这种类型的路径返回“True”,即使它似乎可以很好地用于:
测试路径c:\windows\system3*

此代码段适用于映射的UNC路径:

   Get-PSDrive| where{$_.DisplayRoot -like "\\server\test*" } | foreach{test-path -path $_.DisplayRoot}
如果您具有wmi访问权限,则:

Get-WmiObject -Class Win32_Share -ComputerName server | where{$_.name -like "test*"} | foreach{Test-Path "\\server\$($_.name)"}

此代码段适用于映射的UNC路径:

   Get-PSDrive| where{$_.DisplayRoot -like "\\server\test*" } | foreach{test-path -path $_.DisplayRoot}
如果您具有wmi访问权限,则:

Get-WmiObject -Class Win32_Share -ComputerName server | where{$_.name -like "test*"} | foreach{Test-Path "\\server\$($_.name)"}

我认为Windows不支持共享名的通配符选择

但如果您有足够的(远程)文件服务器访问权限,则可以获得共享列表:

Get-WmiObject -class 'Win32_Share' -ComputerName 'Server'

我认为Windows不支持共享名的通配符选择

但如果您有足够的(远程)文件服务器访问权限,则可以获得共享列表:

Get-WmiObject -class 'Win32_Share' -ComputerName 'Server'

您的路径必须是
\\Server\C$\Path*
。您的路径必须是
\\Server\C$\Path*
。这已经回答了问题,非常感谢。为了完整性,我使用这行代码来识别“Pathx”的存在:
获取WmiObject-class'Win32\u Share'-ComputerName'Server';where Name-Like“*Path*“
回答了这个问题,非常感谢。为了完整起见,我用这一行来区分“Pathx”的存在:
Get WmiObject-class'Win32_Share'-ComputerName'Server';其中Name-Like“*Path*”