< Back

Assert-FileExists

Sun Jan 12, 2020 5:41 pm

NAME Assert-FileExists



SYNOPSIS

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

-Path <String>

The path to the file to check.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

A description of why the assertion might fail.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



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



Demonstrates how to assert that a file exists.









-------------------------- EXAMPLE 2 --------------------------



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



Demonstrates how to describe why an assertion might fail.











RELATED LINKS