Often I receive requests to check the multiple string combinations in the given set of files.It’s really a pain to do all manual check. Here the small PowerShell script to accomplish that.
Requirement:
Request to check the 2 strings in a file with the combination:
Ex: in the file I need to find a string ‘BOB’ and also I need to find another string ‘bought Car’
if ((Get-Content -path filelocation | Select-String -pattern $String1 -Quiet) -and (Get-Content -path filelocation | Select-String -SimpleMatch $String2 -Quiet))
{
‘combination exists’
}
else
{
‘combination not exists’
}
In the next post, I will post about searching multiple strings in the file shares and copy those files in the destination location.
Regards,
Chaitanya