PowerShell - Select secondary drive for install
<p>I have the following installation script that assigns the drive letter if the test-path is true. All our applications are installed on the secondary disk and never the same as the OS (C:). </p>

<pre><code>$DeviceDrive = "C:"
Get-WmiObject win32_logicaldisk -Filter "DriveType=3 AND DeviceID!='C:'" |
Where-Object { Test-Path "$($_.DeviceID)\Apps\" } |
Foreach-Object {
    $DeviceDrive = $_.DeviceID
}
</code></pre>

<p>The path may not exist if it is a new host and I don't want the default drive to be <code>C:</code>. If the path doesn't exist, how would I assign the secondary disk (i.e D:) to <code>$DeviceDrive</code> variable? Note, there may be more then 2 drives and the secondary disk may not be D: i.e. could be F: or even G:. It also needs to work on powershell v2.0 because of 2003 hosts.</p>

<p>I need something along the lines</p>

<pre><code>IF ($Devicedrive -eq "C:"){
# Select secondary disk and assign to $Devicedrive}
</code></pre>

<p>Any ideas?</p>