File size: 806 Bytes
8c763fb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# Precondition: start from fresh PS session, do not have the media mounted
param([switch]$useModule, [string]$FullPath)

$global:CoreScriptPath = Join-Path $PSScriptRoot 'AutomountSubstDriveCore.ps1'

if ($useModule)
{
    $m = New-Module {
        function Test-DrivePresenceFromModule
        {
            param ([String]$Path)

            & $global:CoreScriptPath -Path $Path
        }

        Export-ModuleMember -Function Test-DrivePresenceFromModule
    }
}

try
{
    if ($useModule)
    {
        Import-Module $m -Force
        Test-DrivePresenceFromModule -Path $FullPath
    }
    else
    {
        & $global:CoreScriptPath -Path $FullPath
    }
}
finally
{
    if ($useModule)
    {
        Remove-Module $m
    }
}