Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

How can I used Error Traping / 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 10624

Trending Articles