by link12 at 2012-11-16 08:23:44
How can I trim/split the followingby ArtB0514 at 2012-11-16 09:12:48
aa-computername-cc
aa-computer-name-cc
I basically want to trim the aa- and the -cc, but leave the computer name regardless if it has a "-" or not.
Easy: takes two steps:by link12 at 2012-11-16 09:18:56
1. Split the name on "-"
2. Rejoin the name, skipping the first (id=0) and the last (id=count -1)
$Original = $ComputerName -Split "-"
$Final = (1…($Original.count - 2) | foreach {$Original[$]}) -join "-"
Worked like a charm. Can you briefly explain this lineby link12 at 2012-11-16 09:23:28
$Final = (1…($Original.count - 2) | foreach {$Original[$]}) -join "-"
Thanks
I see your explaination above, nevermind. Thanks again