I have a script that I need to trim the last 7 characters off from a result of a variable.

Example

$X would display \\servername\sharename.

I want to trim everything except the servername. The server name can be any length from 6-10 letters.

I looked a SUBSTR and LTRIM and RTRIM but can get even close.

Help is needed and appreciated.