Avatar of bibi92
bibi92
Flag 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
Powershell

Avatar of undefined
Last Comment
bibi92

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
SubSun

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Meir Rivkin

(Get-ItemProperty "$fullpath\Setup").SQLDataRoot.Split("\")[0..2] -join ("\")

Open in new window

bibi92

ASKER
Thanks bibi
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23