Hello, I am new to powershell and I need to grab a certain part of a text from .txt file as:
ip location
-- --------
75.82.30.5 @{country=RO; region=Bucuresti; city=Bucharest; lat=44.4354; lng=26.1033; postalCode=051527; timezone=+03:00; geonameId=683506}
I need to grab RO part and make it a variable in order to used further
I have this as a code:
New-Item -ItemType directory -Path C:\temp\
cd C:\temp\
Invoke-RestMethod -Method Get -Uri "https://geo.ipify.org/api/v1?apiKey=at_iNhGwrCTwXtgrIVk7wborCRQMpH5Q&ipAddress" > C:\temp\country.txt
$Text = Get-Content -Path C:\temp\country.txt
The project is to rename computer based on IP location + Serial number
Thank you