Skip to content

Instantly share code, notes, and snippets.

@MateuszNad
Last active November 10, 2019 21:16
Show Gist options
  • Save MateuszNad/491940cf20493aa0fe4fbce57bc55ee0 to your computer and use it in GitHub Desktop.
Save MateuszNad/491940cf20493aa0fe4fbce57bc55ee0 to your computer and use it in GitHub Desktop.
$Error.Clear()
$oldErrorActionPreference = $ErrorActionPreference
$ErrorActionPreference = 'SilentlyContinue'
Get-Item -Path F:\file, D:\temp
if(-not $?)
{
Write-Warning $Error[0].Exception.Message
}
$ErrorActionPreference = $oldErrorActionPreference
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment