-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpowershell-aliases.ps1
57 lines (53 loc) · 1.28 KB
/
powershell-aliases.ps1
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
<#
.SYNOPSIS
.
.DESCRIPTION
.
.PARAMETER VagrantFile
The path to the Vagrantfile to use .
.PARAMETER Name
Name of the resulting VM .
.PARAMETER DataDir
Path of the directory to sync with the VM .
.PARAMETER Provision
Whether or not to call vagrant up - ommission of this flag simply copies the Vagrantfile to the current dir .
.PARAMETER Gui
Whether or not to start the VM with a GUI .
.EXAMPLE
V-Init -Vagrantfile "C:\Vagrantfiles\kali\Vagrantfile" -Name "mykali" -DataDir ".\data" -Provision .
.NOTES
Author: Cory Sabol
#>
function V-Init {
param (
[String]$VagrantFile = 'D:\Vagrantfiles\kali\Vagrantfile',
[String]$Name = '',
[String]$DataDir = '.\data',
[switch]$Provision,
[switch]$Gui
)
if ($Name -eq '') {
$p = Split-Path -leaf -path (Get-Location)
$d = Get-Date -UFormat "%m%d%Y"
$Name = "$p-$d"
}
Copy-Item "$VagrantFile" -Destination .
if ($Provision) {
$env:VMNAME=$Name
$env:DATADIR=$DataDir
if ($env) {
$env:GUI=$Gui
}
vagrant up
}
}
function V-Halt {
vagrant halt
}
function V-Destroy {
V-Halt; if ($?) { vagrant destroy --force }
}
# Todo: emit a env file into .Vagrant that can be loaded into the vagrant script for reprovisioning.
function V-Rebuild {
V-Destroy; if ($?) {}
}