Advertisement
Guest User

Untitled

a guest
Jul 17th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. $Error.count # empty automatic variable
  2.  
  3. # throwing an error when file doesn't exists
  4. Get-Item C:\Data\nosuchfile.txt
  5. $Error.count # one error record logged
  6.  
  7. # supressing the error
  8. Get-Item C:\Data\nosuchfile.txt -ErrorAction SilentlyContinue
  9. $Error.count # but still capturing the error
  10.  
  11. # supress the error but not logging it in $Error variable
  12. Get-Item C:\Data\nosuchfile.txt -ErrorAction Ignore
  13. $Error.count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement