Powershell / Providers / Get-ChildItem : Invalid Path

Using UNC paths when working with PowerShell providers.

There are errors you can encounter using UNC paths if your current provider is different then filesystem. PowerShell will just use the current one.

We can use the Get-PSProvider cmdlet to get full list of the PSProviders available on our system. My current one is filesystem.

 

So lets test this. I will use one simple PowerShell script to delete all sub-folders and files from network folder.

 

So, if I change provider from current filesystem to sqlserver

 

and run script again I will get following error.

 

If I change back error is gone.

 

Also, if current provider is not the filesystem provider you can specify provider in folder path, this will solve the issue regardless of PowerShell current provider.

 

In this case even if PowerShell provider is different then filesystem there is no error

 

 

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *