I would like in my script to use wildcard in variable like this :
$TARGET = "\\MACHINE1\c$\ProgramData\Test\12.*\Data\"
The problem is $TARGET returns
\\MACHINE1\c$\ProgramData\Test\12.*\Data\
and not
\\MACHINE1\c$\ProgramData\Test\12.1.1.1\Data\
However
Test-Path "\\MACHINE1\c$\ProgramData\Test\12.*\Data\"
=> TRUE
Thanks for your help
The Best in this cases IMO is using Resolve-Path,
$TARGET = Resolve-Path "\\MACHINE1\c$\ProgramData\Test\12.*\Data\" | Select -ExpandProperty Path
You should use Get-ChildItem
to retrieve the real path:
$TARGET = "\\MACHINE1\c$\ProgramData\Test\12.*\Data\"
Get-ChildItem $Target
Directory: \\MACHINE1\c$\ProgramData\Test\12.1.1.1
Mode LastWriteTime Length Name
---- ------------- ------ ----
d---- 10-10-2014 12:48 data
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With