2 line PowerShell script works on one device, but not the other

Hello,

The below 2 line code at the end of this message does a filter on only *.msi files (there will only be one in the directory, so not worried about multiple *.msi files) to the specified path to only return the name of the *.msi file to a message box and no other information. One one device it works fine and on the other it gets this error message. I did a search on the Internet, but I did not find anything specific to this:

Get-ChildItem : Cannot call method. The provider does not support the use of filters.
At line:1 char:20
+ … aNameOnly = Get-ChildItem -filter *.msi -Path \server\share\Cor …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotImplemented: (:slight_smile: [Get-ChildItem], PSNotSupportedException
+ FullyQualifiedErrorId : NotSupported,Microsoft.PowerShell.Commands.GetChildItemCommand

 

Here is the 2 line code that gets the file name and then sends that output to a message box:

$GetFileNameOnly = Get-ChildItem -filter *.msi -Path \server_name\share_name –Name
[System.Windows.MessageBox]::Show($GetFileNameOnly)

 

Do a pwd and check the current location. Do a Set-Location to filesystem (example c:) and try executing.
IMO, -Filters work for only FileSystem providers, hence you current working directory should be a filesystem type.

Yep, that was it. The default path was set to an SCCM site code share path, so after setting it to c:, it’s all golden now. Thanks for the assist!