With previous versions of VS you could query the registry to determine the installation directory for VS:
HKLM\\SOFTWARE\\Wow6432Node\\Microsoft\\Visu
I use powershell like KindDragon suggested
$Is64bitOs = $env:PROCESSOR_ARCHITEW6432 -eq 'AMD64';
if ($Is64bitOs){
$registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0";
}
else {
$registryPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\14.0";
}
$VSInstallDir = (Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\VisualStudio\14.0 -Name ShellFolder).ShellFolder;