I have an object called $latestBlob_content, this contains logs from azure build pipeline. I want to find a specific string from this object. But when I call - $latestBlob_content | Select-String -Pattern $pattern . This returns the whole logs. Is the 3rd line right way of reading a blob file!?
$blobs = Get-AzStorageBlob -Container $container_name -Context $context | sort @{Expression = "LastModified";Descending=$true}
$latestBlob = $blobs[0]
$latestBlob_content = $latestBlob.ICloudBlob.DownloadText()
$pattern = "Terraform_modules.azure_data_lake.*"
$latestBlob_content | Select-String -Pattern $pattern
Thanks in advance
Code those are not working -
$latestBlob_content.ToString() | Select-String -Pattern "Terraform_modules.azure_data_lake.*"
Select-String -InputObject $latestBlob_content -Pattern $patternalso returns whole logs. no the specified pattern stringSelect-String -Path .\*.txt -Pattern 'Terraform_modules.azure_data_lake.*'$latestBlob_contentis one string instead of an array of strings. You could check the type using$latestBlob_content.GetType(). If that is the case, you essentially pas 1 string toSelect-Stringand ask it if the string contains your pattern and it does so it returns you back the complete string. You could try$latestBlob_content -split "`r?`n" | Select-String -Pattern $pattern