Powershell script to manipulate string.
Sometime you get a list of hostname with fully qualified domain name but you might just need the computer name part.
Here is a powershell script to loop through the list and remove everything after “.” and create a new list with only computer name.
$PreSecond = get-content PreSecond.txt
New-Item "C:\Myworkplace\ps\Second.txt" -Type file
foreach ($Hostname in $PreSecond)
{
$second = $Hostname.split('.')[0]
Add-content "C:\Myworkplace\ps\Second.txt" $second
}