Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How can I used Error Trapping / Error Action with .NET type

$
0
0

Hello

I wounder if someone can help me with the following question please.

If I do the following

[System.IO.Directory]::EnumerateFiles("\\Server1\Directory1","*.ps1",AllDirectories)

I get a list of files under remote Servers Directory 1 share that are of type .ps1 OK simply enough. Now if I hit a directory/files where I do not have access it will throw an Access Denined exception and the stop there, i.e. not going on the list any futher files. So basically I want to be able to do -ErrorAction SilentlyContinue  for example

I have tried using invoke-command {.....} -ErrorAction SilentlyContinue

but not joy

Any suggestion please around this subject, do I need to add some C# code to my PowerShell script?

Thanks All

Ernie


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>