Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

The specified wildcard pattern is not valid: [

1,308 views
Skip to first unread message

Thomas Friis Poulsen

unread,
Nov 27, 2008, 6:09:35 AM11/27/08
to
Hi All

This:
Get-Acl -Path \\server\f$\Home\B\[Foldername

Gives the error "The specified wildcard pattern is not valid: [foldername
if the share has a folder with a name that include a [
Is this a bug or ???

Best Regards

Thomas

Vadims Podans

unread,
Nov 27, 2008, 8:35:03 AM11/27/08
to
if "[" is in filename start, then:
get-acl \\server\f$\Home\B\[[]*

if "[" is in filename middle then:
get-acl \\server\f$\Home\B\*[[]*

if "[" is in filename end, then:
get-acl \\server\f$\Home\B\*[[]

enjoy!
--
WBR Vadims Podans
PowerShell blog: www.sysadmins.lv

Kiron

unread,
Nov 27, 2008, 2:06:02 PM11/27/08
to
Unfortunately Get-ACL does not have a -LiteralPath, if it did you could do:
Get-ACL -literalPath \\server\f$\Home\B\[Foldername

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #
Get-ACL's -Path parameter accepts piped input by value and by property name.
Square brackets in a path must be escaped before piping them to some Cmdlets.
The filter below escapes square brackets in the item's PSPath property.
Get-ACL's -Path parameter has the alias PSPath, this means that after retrieving the item with Get-Item or Get-ChildItem by substituting the square brackets with the wildcard '?', we can then pipe the item to Escape-Bracket and pipe the temporarily modified item to Get-ACL, the item's modified PSPath will bind to the aliased -Path parameter by property name.

filter Escape-Bracket {
$_.psPath = $_.psPath -replace '\[|]','`$0'
$_
}
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - #

Try this workaround:
# substitute the bracket with the wildcard '?', pipe it to the Filter
# and pipe the modified item to Get-ACL
gi \\server\f$\Home\B\?Foldername | Escape-Bracket | get-acl

--
Kiron

VEKk

unread,
May 18, 2010, 11:08:01 AM5/18/10
to
so, on my host
PS Z:\test> $host.version

Major Minor Build Revision
----- ----- ----- --------
2 0 -1 -1

all replies marked as Answer don't work now

0 new messages