Assert-FileDoesNotContain

Asserts that a file doesn not contain a string.

Syntax

Assert-FileDoesNotContain [[-Path] <String>] [[-Needle] <String>] [[-Message] <Object>] [<CommonParameters>]

Description

Assert-FileDoesNotContain searches a file for a string and fails if that string isf ound.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String

The path to the file.

false false
Needle String

The string to not look for.

false false
Message Object

A description about why the assertion might have failed.

false false

EXAMPLE 1

Assert-FileDoesNotContain 'C:\Windows\System32\drivers\etc\hosts' '127.0.0.1'

Demonstrates how to assert that a file does not contain a string.

EXAMPLE 2

Assert-FileDoesNotContain 'C:\Windows\System32\drivers\etc\hosts' 'doubclick.net' 'Ad-blocking hosts entry not added.'

Shows how to use the Message parameter to describe why the assertion might fail.