Asked by:
howto cut specific character or line

Question
-
policy 1-TFS-DB-SQL\, schedule Default-Application-Backup,10/31/2019 02:57:31 - Info nbjm(pid=7116) requesting STANDARD_RESOURCE resources from RB for backupTFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025712..C,1,9136,MSDP-POOL-STU,access-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was successfully completed,TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025712..C,1,9136,MSDP-POOL-STU,access-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was successfully completed,
We only want to pick TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.a from above paragraph
Any comment will be appreciated. Thanks. Zahid Haseeb.
- Edited by ZahidHaseeb Friday, November 1, 2019 11:04 AM
Friday, November 1, 2019 11:03 AM
All replies
-
What have you tried so far? Please show your code. We do not deliver ready to use solutions on request.
And please format any code or sample data as code using the code posting tool: How to Use the Code Feature in a TechNet Forum Post
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Friday, November 1, 2019 11:57 AM -
Select-String -Path "c:\FILEPATH" -Pattern 'TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.'
Also tried
Get-ChildItem -Path C:\FILEPATH -Recurse | Select-String -Pattern ''TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.'' -CaseSensitive
Below example is for reference. It picks all paragraph.
PS C:\Users\zahid.haseeb\Documents> Select-String -Path "C:\Users\zahid.haseeb\Documents\test.txt" -Pattern 'TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.'
test.txt:1:policy 1-TFS-DB-SQL\, schedule Default-Application-Backup,10/31/2019 02:57:31 - Info nbjm(pid=7116)
requesting STANDARD_RESOURCE resources from RB for backupTFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025
712..C,1,9136,MSDP-POOL-STU,access-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was
successfully completed,TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025712..C,1,9136,MSDP-POOL-STU,access
-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was successfully completed,
Any comment will be appreciated. Thanks. Zahid Haseeb.
- Edited by ZahidHaseeb Friday, November 1, 2019 12:12 PM
Friday, November 1, 2019 12:06 PM -
Please format any code or sample data as code using the code posting tool: How to Use the Code Feature in a TechNet Forum Post
Live long and prosper!
(79,108,97,102|%{[char]$_})-join''
Friday, November 1, 2019 12:29 PM -
Try this:
$str = "policy 1-TFS-DB-SQL\, schedule Default-Application-Backup,10/31/2019 02:57:31 - Info nbjm(pid=7116) requesting STANDARD_RESOURCE resources from RB for backupTFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025712..C,1,9136,MSDP-POOL-STU,access-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was successfully completed,TFSDB.MSSQL7.TFSDB.db.TFS02_Warehouse.~.7.001of001.20191031025712..C,1,9136,MSDP-POOL-STU,access-bkp.accessonline.com,1572472651,0000000337,1572472988,0,the requested operation was successfully completed" if ($str -match "(TFSDB\.MSSQL7\.TFSDB\.db\.TFS02_Warehouse\.)"){ Write-Host $matches[1] }
--- Rich Matheisen MCSE&I, Exchange Ex-MVP (16 years)
- Proposed as answer by LeeSeenLiMicrosoft contingent staff Friday, December 6, 2019 9:50 AM
Friday, November 1, 2019 4:02 PM