I am trying to create a script that select the four numbers that the company computer have in the host name.
I have tested the regex '\d{4}' in a regex web site, and it works fine to select the four numbers. but when using it with powershell y only get the $true or $false.
I need that the 4 numbers are keept in a variable for later use but i havent achieved it.
any ideas??
$machinename = "mac0016w701"
$test = $machinename -match '\d{4}'
$test2= Select-String -Pattern '\d{4}' -inputobject $machinename
$test2