Asserts that a file contains another string.
Assert-FileContains [[-Path] <String>] [[-Needle] <String>] [[-Message] <Object>] [<CommonParameters>]
Performs a case-sensitive check for the string within the file.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
Path | String | The path to the file. |
false | false | |
Needle | String | The string to look for. Case-sensitive. |
false | false | |
Message | Object | A description about why the assertion might have failed. |
false | false |
Assert-FileContains 'C:\Windows\System32\drivers\etc\hosts' '127.0.0.1'
Demonstrates how to assert that a file contains a string.
Assert-FileContains '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.