Split through Powershell on a file content


hello all,
need in extracting specific values line. have log file generates big file , need read each line , collect values in it. me on this

for example:
*error|2017-02-06 10:10:42,942|090jj48e-e8j3-428h-949a-855448adsdf87|webserver001|10.0.0.1|0.9284515|post|500|/mybuildings/api/v1/bookings|{"roomid":"r123456789","owner":"ranji@gmail.com","mandatoryparticipants":["alex.max@test.com"],"object":"reservation on control"}|errormessage: unable create booking roomid, error while checking if owner authorized book room: r123456789,  owner: ranji@test.com,  startdate: 2/8/2017 3:00:00 pm, enddate: 2/8/2017 4:00:00 pm. exception: system.management.automation.remoting.psremotingtransportexception: connecting remote server exchangeserver001.test.com failed following error message : illegal operation attempted on registry key has been marked deletion. more information, see about_remote_troubleshooting topic.


each line have above content (similar format)

i extract content through get-content , reach out each line, after how can collect following attributes?
need extract following components in different variables:
1. r123456789 (which next "roomid")
2. ranji@test.com (which next "owner")
3. errormessage (errormessage: unable create booking roomid, error while checking if owner authorized book room: r123456789,  owner: ranji@test.com,  startdate: 2/8/2017 3:00:00 pm, enddate: 2/8/2017 4:00:00 pm)
4. exception (system.management.automation.remoting.psremotingtransportexception: connecting remote server exchangeserver001.test.com failed following error message : illegal operation attempted on registry key has been marked deletion. more information, see about_remote_troubleshooting topic.)


never giveup till want.

the file in json format. use "convertfrom-json" , create objects.

d:\scripts> $json = '{ "roomid":"r123456789", "owner":"ranji@gmail.com", "mandatoryparticipants":["alex.max@test.com"], "object":"reservation on control" }'|convertfrom-json d:\scripts> $json.owner ranji@gmail.com d:\scripts> $json.roomid r123456789 d:\scripts> $json|fl   roomid                : r123456789 owner                 : ranji@gmail.com mandatoryparticipants : {alex.max@test.com} object                : reservation on control 


\_(ツ)_/




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Event ID 64,77,1008 Certificates Events Windows Server 2008, 2008R2