Assert-FileExists

Asserts that a file exists.

Syntax

Assert-FileExists [[-Path] <String>] [[-Message] <String>] [<CommonParameters>]

Description

Uses PowerShell's Test-Path cmdlet to check if the file exists.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the file to check.

false false
Message String

A description of why the assertion might fail.

false false

EXAMPLE 1

Assert-FileExists 'C:\Windows\system32\drivers\etc\hosts'

Demonstrates how to assert that a file exists.

EXAMPLE 2

Assert-FileExists 'C:\foobar.txt' 'Foobar.txt wasn''t created.'

Demonstrates how to describe why an assertion might fail.