Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

powershell extract string

Hello,

In a script, I execute :

$sql=(Get-ItemProperty "$fullpath\Setup").SQLDataRoot
echo $sql :
Z:\mssql\INST1\MSSQL10_50.INST1\MSSQL\data\MSSQL10_50.INST1\MSSQL
How can I extract Z:\mssql\INST1?

Thanks

Regards

bibi
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(Get-ItemProperty "$fullpath\Setup").SQLDataRoot.Split("\")[0..2] -join ("\")

Open in new window

Avatar of bibi92

ASKER

Thanks bibi