Skip to content

Commit 573c8cd

Browse files
author
Jaromir Kaspar
authored
Merge pull request #393 from microsoft/dev
Dev
2 parents a38eb5e + 9469826 commit 573c8cd

36 files changed

+913
-5
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Verify Running as Admin
2+
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")
3+
If (-not $isAdmin) {
4+
Write-Host "-- Restarting as Administrator" -ForegroundColor Cyan ; Start-Sleep -Seconds 1
5+
6+
if($PSVersionTable.PSEdition -eq "Core") {
7+
Start-Process pwsh.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
8+
} else {
9+
Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs
10+
}
11+
exit
12+
}
13+
14+
$folder=$PSScriptRoot
15+
#$folder="c:\temp"
16+
17+
[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
18+
$openFiles = New-Object System.Windows.Forms.OpenFileDialog -Property @{
19+
Multiselect = $true;
20+
Title="Please select msix file(s)"
21+
}
22+
$openFiles.Filter = "msix files (*.msix)|*.msix"
23+
24+
25+
If($openFiles.ShowDialog() -eq "OK"){
26+
Write-Host "Selected Files:" -ForegroundColor Cyan
27+
foreach ($filename in $openFiles.Filenames){
28+
Write-Host "`t $FileName" -ForegroundColor Cyan
29+
}
30+
}
31+
32+
#Download MSIX Image tool if not available"
33+
if (!(Test-Path "$folder\msixmgr\x64\msixmgr.exe")){
34+
Invoke-WebRequest -Uri https://aka.ms/msixmgr -OutFile "$folder\msixmgr.zip"
35+
Expand-Archive -Path "$folder\msixmgr.zip" -DestinationPath "$folder\msixmgr"
36+
}
37+
38+
foreach ($File in $openFiles.FileNames){
39+
$appname=($file | Split-Path -Leaf).TrimEnd(".msix")
40+
if (!(test-path -Path $folder)){
41+
New-Item -Path $folder -ItemType Directory
42+
}
43+
$vhd=New-VHD -SizeBytes 100GB -path $folder\$appname.vhdx -dynamic -confirm:$false
44+
#mount and format VHD
45+
$VHDMount=Mount-VHD $vhd.Path -Passthru
46+
$vhddisk = $vhdmount | Get-Disk
47+
$vhddiskpart = $vhddisk | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -AssignDriveLetter | Format-Volume -Filesystem NTFS -AllocationUnitSize 8kb -NewFileSystemLabel $appname
48+
49+
Start-Process -FilePath "$folder\msixmgr\x64\msixmgr.exe" -ArgumentList "-Unpack -packagePath `"$File`" -destination $($vhddiskpart.driveletter):\ -applyacls" -Wait
50+
51+
Dismount-VHD $vhddisk.number
52+
}
53+
54+
Read-Host "job done. Press enter to exit"
55+

Scenarios/AppAttach/LabConfig.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#sample labconfig with enabled telemetry (Full)
2+
3+
$LabConfig=@{ DomainAdminName='LabAdmin'; AdminPassword='LS1setup!'; Prefix = 'WSLab-'; SwitchName = 'LabSwitch'; DCEdition='4'; Internet=$true ; TelemetryLevel='Full' ; TelemetryNickname='' ; AdditionalNetworksConfig=@(); VMs=@()}
4+
5+
#$LabConfig.VMs += @{ VMName = 'Management' ; ParentVHD = 'Win2019_G2.vhdx'; MGMTNICs=1}
6+
$LabConfig.VMs += @{ VMName = 'Win10' ; ParentVHD = 'Win1020H1_G2.vhdx'; MGMTNICs=1 ; EnableWinRM=$true}
7+
$LabConfig.VMs += @{ VMName = 'Win10_1' ; ParentVHD = 'Win1020H1_G2.vhdx'; MGMTNICs=1 ; EnableWinRM=$true}
8+
#$LabConfig.VMs += @{ VMName = 'Win10_2' ; ParentVHD = 'Win1020H1_G2.vhdx'; MGMTNICs=1 ; EnableWinRM=$true}
713 KB
Loading
256 KB
Loading
312 KB
Loading
90.9 KB
Loading
20.2 KB
Loading
20.7 KB
Loading
25.3 KB
Loading
28.5 KB
Loading

0 commit comments

Comments
 (0)