Skip to content

Commit

Permalink
JCore brownfield app attach vm fix script for tools setup (#691)
Browse files Browse the repository at this point in the history
* Update AppAttachVMConfig.ps1

Included update notes on header.

* Update AppAttachVMConfig.ps1

* Update AppAttachVMConfig.ps1

* Update AppAttachVMConfig.ps1

* Update AppAttachVMConfig.ps1

Removed script cut/paste duplicate
  • Loading branch information
JCoreMS authored Oct 22, 2024
1 parent d891033 commit 93a9b5c
Showing 1 changed file with 28 additions and 32 deletions.
60 changes: 28 additions & 32 deletions workload/scripts/appAttachToolsVM/AppAttachVMConfig.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
# Purpose:
# Configure VM for App Attach package creation. Installs PsfTooling and MSIX App Attach Windows Store based applications and sets recommended registry settings.
# Configure VM for App Attach package creation. Installs MSIX App Attach Windows Store based application, MSIX Tools Driver, and sets recommended registry settings.

# Updates:
# 8/28/2023 (JCore) - Updated from original to remove Drive Mapping, add latest package versions, create desktop shortcuts and remove startup for Windows and Edge.
#
<#
Updates:
8/28/2023 (JCore) - Updated from original to remove Drive Mapping, add latest package versions, create desktop shortcuts and remove startup for Windows and Edge.
10/21/2024 (JCore) - Removed PSFTooling as it's now included in MSIX Tools, added download and install for the MSIX Tools Driver ahead of time, updated URL and
version for MSIX Tools install. Changed Install from Add-AppPackage to Add-AppxProvisionedPackage.
#>

Param(

Expand All @@ -19,11 +22,13 @@ Param(

# URLs for MSIX and PsfTooling packages
# version 1.2023.319.0
$MSIXPackageURL = "https://download.microsoft.com/download/d/0/0/d0043667-b1db-4060-9c82-eaee1fa619e8/493b543c21624db8832da8791ebf98f3.msixbundle"
$PsfToolPackageURL = "https://www.tmurgent.com/AppV/Tools/PsfTooling/PsfTooling-6.3.0.0-x64.msix"
$MSIXPackageURL = "https://download.microsoft.com/download/e/2/e/e2e923b2-7a3a-4730-969d-ab37001fbb5e/MSIXPackagingtoolv1.2024.405.0.msixbundle"
# $PsfToolPackageURL = "https://www.tmurgent.com/AppV/Tools/PsfTooling/PsfTooling-6.3.0.0-x64.msix"

$AppAttachInstallFolder = "Microsoft.MSIXPackagingTool_1.2023.319.0_x64__8wekyb3d8bbwe"
$PsfToolInstallFolder = "PsfTooling_6.3.0.0_x64__4y3s55xckzt36"
$AppAttachInstallFolder = "Microsoft.MSIXPackagingTool_1.2024.405.0_x64__8wekyb3d8bbwe"
# $PsfToolInstallFolder = "PsfTooling_6.3.0.0_x64__4y3s55xckzt36"

$MSIXToolsDriver = "Msix.PackagingTool.Driver~~~~0.0.1.0"

# Create Log file for output and troublehsooting
$Log = "C:\PostConfig.log"
Expand Down Expand Up @@ -112,12 +117,6 @@ Invoke-WebRequest -Uri $MSIXPackageURL -OutFile "C:\MSIX\MsixPackagingTool.msixb
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }

# Download the PFSTooling Tool
"Downloading PSFTooling Tool" | Out-File $Log -Append
Invoke-WebRequest -URI $PsfToolPackageURL -OutFile "C:\MSIX\PsfTooling-x64.msix"
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }

"Enabling PSRemoting" | Out-file $Log -Append
Enable-PSRemoting -Force
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Expand All @@ -126,30 +125,31 @@ Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }
Invoke-Command -ComputerName $ENV:COMPUTERNAME -Credential $VMCredential -ScriptBlock {
# Installs the MSIX Packaging Tool
"Installing MSIX Packaging Tool as $Using:VMUserName" | Out-File $Using:Log -Append
Add-AppPackage -Path "C:\MSIX\MSIXPackagingTool.msixbundle"
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Using:Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Using:Log -Append; $Error.Clear() }

# Downloads and installs the PFSTooling Tool
"Installing PSFTooling Tool as $Using:VMUserName" | Out-File $Using:Log -Append
Add-AppPackage -Path "C:\MSIX\PsfTooling-x64.msix"
Add-AppxPackage -Path "C:\MSIX\MSIXPackagingTool.msixbundle"
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Using:Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Using:Log -Append; $Error.Clear() }
<# # Map Drive for MSIX Share
<#
# Map Drive for MSIX Share
"Mapping MSIX Share to M:" | Out-File $Log -Append
New-PSDrive -Name M -PSProvider FileSystem -Root $Using:FileShare -Credential $Using:StorageCredential -Persist
# New-SmbGlobalMapping -RemotePath $FileShare -Credential $Credential -LocalPath 'M:'
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Using:Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Using:Log -Append; $Error.Clear() } #>

Else { "-----ERROR-----> $Error" | Out-File $Using:Log -Append; $Error.Clear() }
#>
}

# Disable PSRemoting after Invoke Command
"Disabling PSRemoting" | Out-file $Log -Append
Disable-PSRemoting -Force
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }

# Install MSIX Packaging Tools Driver (Req'd at first launch if not installed)
"Installing MSIX Packaging Tool Driver" | Out-File $Log -Append
Add-WindowsCapability -Online -Name $MSIXToolsDriver
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }

# Stops the Shell HW Detection service to prevent the format disk popup
"Stoping Plug and Play Service and setting to disabled" | Out-file $Log -Append
Stop-Service -Name ShellHWDetection -Force
Expand Down Expand Up @@ -185,19 +185,15 @@ Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }
$DestinationPath = "C:\Users\Public\Desktop"
$AppAttach = "$DestinationPath\MSIX App Attach.lnk"
$AppAttachExe = "C:\Program Files\WindowsApps\$AppAttachInstallFolder\MsixPackageTool.exe"
$PSFToolExe = "C:\Program Files\WindowsApps\$PsfToolInstallFolder\PsfTooling.exe"
$PSFTool = "$DestinationPath\PSFTool.lnk"
# $PSFToolExe = "C:\Program Files\WindowsApps\$PsfToolInstallFolder\PsfTooling.exe"
# $PSFTool = "$DestinationPath\PSFTool.lnk"
$MSIXfldr = "$DestinationPath\MSIX Folder.lnk"
$MSIXfldrLoc = "C:\MSIX\"
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($AppAttach)
$Shortcut.TargetPath = $AppAttachExe
$Shortcut.Save()
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($PSFTool)
$Shortcut.TargetPath = $PSFToolExe
$Shortcut.Save()
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($MSIXfldr)
$Shortcut.TargetPath = $MSIXfldrLoc
$Shortcut.Save()
Expand All @@ -209,4 +205,4 @@ Restart-Computer -Force
If ($Error.Count -eq 0) { ".... COMPLETED!" | Out-File $Log -Append }
Else { "-----ERROR-----> $Error" | Out-File $Log -Append; $Error.Clear() }

"-------------------------- END SCRIPT RUN ------------------------" | Out-File $Log -Append
"-------------------------- END SCRIPT RUN ------------------------" | Out-File $Log -Append

0 comments on commit 93a9b5c

Please sign in to comment.