< Back
Assert-FileContains
Post
NAME Assert-FileContains
SYNOPSIS
Asserts that a file contains another string.
SYNTAX
Assert-FileContains [[-Path] <String>] [[-Needle] <String>] [[-Message] <Object>] [<CommonParameters>]
DESCRIPTION
Performs a case-sensitive check for the string within the file.
PARAMETERS
-Path <String>
The path to the file.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Needle <String>
The string to look for. Case-sensitive.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <Object>
A description about why the assertion might have failed.
Required? false
Position? 3
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-FileContains 'C:\\Windows\\System32\\drivers\\etc\\hosts' '127.0.0.1'
Demonstrates how to assert that a file contains a string.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>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.
RELATED LINKS
SYNOPSIS
Asserts that a file contains another string.
SYNTAX
Assert-FileContains [[-Path] <String>] [[-Needle] <String>] [[-Message] <Object>] [<CommonParameters>]
DESCRIPTION
Performs a case-sensitive check for the string within the file.
PARAMETERS
-Path <String>
The path to the file.
Required? false
Position? 1
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Needle <String>
The string to look for. Case-sensitive.
Required? false
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
-Message <Object>
A description about why the assertion might have failed.
Required? false
Position? 3
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-FileContains 'C:\\Windows\\System32\\drivers\\etc\\hosts' '127.0.0.1'
Demonstrates how to assert that a file contains a string.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>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.
RELATED LINKS