Asserts that a file doesn not contain a string.
Assert-FileDoesNotContain [[-Path] <String>] [[-Needle] <String>] [[-Message] <Object>] [<CommonParameters>]
Assert-FileDoesNotContain
searches a file for a string and fails if that string isf ound.
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 |
Assert-FileDoesNotContain 'C:\Windows\System32\drivers\etc\hosts' '127.0.0.1'
Demonstrates how to assert that a file does not contain a string.
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.