我想在我的脚本中使用通配符变量如下:
$TARGET = "\MACHINE1c$ProgramDataTest12.*Data"
问题是$TARGET返回
\MACHINE1c$ProgramDataTest12.*Data
和
\MACHINE1c$ProgramDataTest12.1.1.1Data
然而Test-Path "\MACHINE1c$ProgramDataTest12.*Data"
=> TRUE
谢谢你的帮助
在这种情况下IMO使用的是Resolve-Path,
$TARGET = Resolve-Path "\MACHINE1c$ProgramDataTest12.*Data" | Select -ExpandProperty Path
您应该使用Get-ChildItem
来检索真实路径:
$TARGET = "\MACHINE1c$ProgramDataTest12.*Data"
Get-ChildItem $Target
Directory: \MACHINE1c$ProgramDataTest12.1.1.1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10-10-2014 12:48 data