powershell ii command related question

this is a question related to my previous question: using ii to open folder in explorer

ii c:\p*  - works

ii \\servername\l* - does not work - does not give any errors as well
ii \\servername\logs - works

I would appreciate if you could help me with opening explorer using folder name pattern.

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jose Gabriel Ortega CastroCEO Faru Bonon IT - EE Solution ExpertCommented:
What is the context of the previous question?.

I just tested using \\Server\Share\Path\

ii \\ServerName\C$\Temp\*lan*

Open in new window

Opens up:




Are you running with sufficient permissions still?

In "\\servername\l*", "l*" is not a folder, but a share.
Invoke-Item can only open a valid file system path, not a UNC with a partial share name.
It does not enumerate shares, which is what you're trying to do with "\\servername\l*".
You can save this as Invoke-Share.ps1 and use it instead:
Opens a share on a remote system in Windows Explorer.
The function Invoke-Share opens a share on a remote system in Windows Explorer.
Wildcard characters are accepted as part of the share or using the -Filter argument.
The UNC to connect to; wildcard characters are accepted.
Note: any directory components after the share will be IGNORED.
Specifies a filter. The value of this parameter qualifies the Path parameter.
Only enumerates the shares the function would normally open.
Asks for confirmation before opening a share.
This function does not generate pipeline output.
Invoke-Share -Path \\Server\*$
Invoke-Share -Path \\Server -Filter *$
[CmdletBinding(SupportsShouldProcess=$true, ConfirmImpact='Low')]
	[Parameter(Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName=$true)]
	Begin {
		$CommandFilter = If ($Filter) {{$_ -like $Filter}} Else {{$true}}
	Process {
		$Path | ForEach-Object {
			$ComputerName, $Share = If ($_.Contains('\')) {$_.Split('\', [StringSplitOptions]::RemoveEmptyEntries)[0..1]} Else {$_, $null}
			$PathFilter = If ($Share) {{$_ -like $Share}} Else {{$true}}
			$StdErr = $(
				& "${ENV:SystemRoot}\system32\net.exe" view /all "\\$($ComputerName)" |
				Where-Object {$_ -match '(?<Name>\A.*?)\s+Disk\b'} |
				ForEach-Object {$Matches['Name']} |
				Where-Object $PathFilter |
				Where-Object $CommandFilter |
				ForEach-Object {
					$UNC = "\\$($ComputerName)\$($_)"
					If ($PSCmdlet.ShouldProcess($UNC, 'Open Share')) {Invoke-Item -Path $UNC -Confirm:$false -WhatIf:$false}
			) 2>&1
			If ($StdErr) {Write-Error "$($ComputerName): $(($StdErr -join ' ').Replace("`r`n", ' '))"}
	End {

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
DevSupportAuthor Commented:
@oBdA: Thank You so much oBdA! Works for me!!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.