#icacls "C:\ProgramData\CompanyPortalOffline" /grant Users:RX /T $Source = "C:\ProgramData\CompanyPortalOffline" $Arch = switch ((Get-CimInstance Win32_Processor).Architecture) { 0 { "x86" } 5 { "arm" } 9 { "x64" } 12 { "arm64" } default { "x64" } } $MainPackage = Get-ChildItem -Path $Source -Recurse -Include *.appxbundle,*.msixbundle | Where-Object { $_.Name -match "CompanyPortal|Microsoft\.CompanyPortal" } | Select-Object -First 1 $Dependencies = Get-ChildItem -Path $Source -Recurse -Include *.appx,*.msix | Where-Object { $_.Name -notmatch "CompanyPortal" -and ( $_.Name -match "_$Arch" -or $_.Name -match "_neutral_" -or $_.Name -notmatch "_(x86|x64|arm|arm64)_" ) } if (-not $MainPackage) { throw "Could not find the Company Portal .appxbundle or .msixbundle under $Source" } Write-Host "Installing: $($MainPackage.FullName)" Write-Host "Dependencies:" $Dependencies.FullName if ($Dependencies) { Add-AppxPackage -Path $MainPackage.FullName -DependencyPath $Dependencies.FullName -ForceApplicationShutdown } else { Add-AppxPackage -Path $MainPackage.FullName -ForceApplicationShutdown }