-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkFormat.ps1
More file actions
123 lines (97 loc) · 3.77 KB
/
bulkFormat.ps1
File metadata and controls
123 lines (97 loc) · 3.77 KB
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
param (
[Parameter(Position=1, Mandatory=$false, HelpMessage="Specify SSD: yes or no")]
[ValidateSet("yes","no", "all")]
[string]$ssd,
[Parameter(Position=2, Mandatory=$false, HelpMessage="Specify default location: us-north-central, us-east, etc.")]
[string]$azureLocation
)
Function Get-FileName($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.Title = "Choose file to import"
$OpenFileDialog.InitialDirectory = $initialDirectory
$OpenFileDialog.Filter = "CSV (*.csv)| *.csv"
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.Filename
}
Function Save-FileName($initialDirectory)
{
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$OpenFileDialog = New-Object System.Windows.Forms.FolderBrowserDialog
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.SelectedPath
}
$fileName = 'vmchooser.csv'
$contractTypes = 'payg', 'ri1y', 'ri3y'
$inputFile = Get-FileName
$outputPath = Save-Filename
$allVMs = Import-Csv $inputFile
Start-Process https://www.vmchooser.com/bulkuploader
$colName = "VM Name"
$colregion = "Region"
$colCores = "Cores"
$colMem = "Memory (GB)"
$colSSD = "SSD"
$colNics = "NICs"
$colDiskSize = "Max Disk Size (TB)"
$colIops = "IOPS"
$colThroughput = "Throughput (MB/s)"
$colMinTemp = "Min Temp Disk Size (GB)"
$colPeakCPU = "Peak CPU Usage (%)"
$colPeakMem = "Peak Memory Usage (%)"
$colCurrency = "Currency"
$colContract = "Contract"
$colBurst = "Burstable"
$colHANA = "SAPHANA"
$colSAP2 = "SAPS2T"
$colSAP3 = "SAPS3T"
$colSisla = "SISLA"
$colOverrideDisk = "OVERRIDEDISKTYPE"
$colOS = "OS"
$colOSDisk = "OSDISK"
$iops = '500'
$throughput = '25'
$tempDiskSize = '10'
$peakCPU= '100'
$peakMem = '100'
$currency = 'USD'
$burstable = 'No'
$azureLocation = 'us-east'
$vmHANA = 'No'
$vmSAP2 = ''
$vmSAP3 = ''
$vmSISLA = 'No'
$vmOverride = 'No'
$osDisk = ''
$i = 0
foreach ($actype in $contractTypes) {
$contract = $contractTypes[$i]
$outputFile = $outputPath + "\" + $contractTypes[$i] + "-" + $fileName
If (Test-Path $outputFile) {Remove-Item $outputFile}
Add-Content -Path $outputFile -Value "$colName,$colregion,$colCores,$colMem,$colSSD,$colNics,$colDiskSize,$colIops,$colThroughput,$colMinTemp,$colPeakCPU,$colPeakMem,$colCurrency,$colContract,$colBurst,$colHANA,$colSAP2,$colSAP3,$colSisla,$colOverrideDisk,$colOS,$colOSDisk"
$i ++
foreach ($vm in $allVMs) {
$vmName = $vm.Name
$vmCores = $vm.CPUs
$vmMem = $vm.Memory / 1000
$vmMem = [math]::Round($vmMem)
$vmDiskSize = $vm.Storage / 1000
$vmDiskSize = [math]::Round($vmDiskSize, 3)
$vmNics = $vm.NICs
$vmSSD = $vm.SSD
$os = $vm.OS
$region = $vm.Region
If ($vm.Region -eq '') { $region = $azureLocation }
If ($vm.Region -eq $null) { $region = $azureLocation }
If ($vm.SSD -eq '') { $vmSSD = $ssd }
If ($vm.NICs -eq '') { $vmNics = 1}
If ($vm.OS -like "*linux*") {$vm.OS = "linux"}
If ($vm.OS -like "*cent*") {$vm.OS = "linux"}
If ($vm.OS -like "*windows*") {$vm.OS = "windows"}
If ($vm.OS -like "*other*") {$vm.OS = "windows"}
If ($vm.OS -eq "") {$vm.OS = "linux"}
$fileContent = $vmName + "," + $region + "," + $vmCores + "," + $vmMem + "," + $vmSSD + "," + $vmNics + "," + $vmDiskSize + "," + $iops + "," + $throughput + "," + $tempDiskSize + "," + $peakCPU+ "," + $peakMem + "," + $currency + "," + $contract + "," + $burstable + "," + $vmHANA + "," + $vmSAP2 + "," + $vmSAP3 + "," + $vmSISLA + "," + $vmOverride + "," + $os + "," + $osDisk
Add-Content -Path $outputFile -Value $fileContent
}
}