-
Notifications
You must be signed in to change notification settings - Fork 8
/
WindowsSandboxTools.psm1
102 lines (86 loc) · 2.56 KB
/
WindowsSandboxTools.psm1
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#turn on verbose output
if ($MyInvocation.line -match "Verbose") {
$VerbosePreference = "Continue"
}
#region class definitions
Write-Verbose "Defining classes"
#these need to be in the module file
Class wsbMetadata {
[string]$Author = $env:USERNAME
[string]$Name
[string]$Description
[datetime]$Updated
wsbMetadata([string]$Name) {
$this.Name = $Name
}
wsbMetadata([string]$Name, [string]$Description) {
$this.Name = $Name
$this.Description = $Description
}
}
Class wsbMappedFolder {
[string]$HostFolder
[string]$SandboxFolder
[bool]$ReadOnly = $True
wsbMappedFolder([string]$HostFolder, [string]$SandboxFolder, [bool]$ReadOnly) {
$this.HostFolder = $HostFolder
$this.SandboxFolder = $SandboxFolder
$this.ReadOnly = $ReadOnly
}
}
Class wsbConfiguration {
[ValidateSet("Default", "Enable", "Disable")]
[string]$vGPU = "Default"
[string]$MemoryInMB = 4096
[ValidateSet("Default", "Enable", "Disable")]
[string]$AudioInput = "Default"
[ValidateSet("Default", "Enable", "Disable")]
[string]$VideoInput = "Default"
[ValidateSet("Default", "Disable")]
[string]$ClipboardRedirection = "Default"
[ValidateSet("Default", "Enable", "Disable")]
[string]$PrinterRedirection = "Default"
[ValidateSet("Default", "Disable")]
[string]$Networking = "Default"
[ValidateSet("Default", "Enable", "Disable")]
[string]$ProtectedClient = "Default"
[string]$LogonCommand
[wsbMappedFolder[]]$MappedFolder
[wsbMetadata]$Metadata
}
#endregion
#dot source the module functions
Get-ChildItem -Path $psscriptroot\functions\*.ps1 |
ForEach-Object {
Write-Verbose "Dot source $($_.fullname)"
. $_.fullname
}
#only define variables if they don't already exist.
Write-Verbose "Configuring global variables"
#define a global variable for the configuration directory
Try {
[void](Get-Variable -Name wsbConfigPath -Scope global -ErrorAction Stop)
}
Catch {
$global:wsbConfigPath = "$psscriptroot\wsbconfig"
}
#define a global variable for configuration scripts
Try {
[void](Get-Variable -Name wsbScripts -Scope global -ErrorAction Stop)
}
Catch {
$global:wsbScripts = "$psscriptroot\wsbScripts"
}
$msg = @"
Using these global variables
Windows Sandbox Tools
---------------------
`$wsbConfigPath = $wsbConfigPath
`$wsbScripts = $wsbScripts
You may want to change these values.
"@
Write-Verbose $msg
#Turn off module scoped Verbose output
if ($VerbosePreference = "Continue") {
$VerbosePreference = "SilentyContinue"
}