#Requires -Version 5.1 [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)][string]$InstallerPath ) $ErrorActionPreference = 'Stop' $identity = [Security.Principal.WindowsIdentity]::GetCurrent() $principal = [Security.Principal.WindowsPrincipal]::new($identity) if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Run the FSLogix installer from an elevated Windows PowerShell session.' } $appsRoot = Join-Path $env:ProgramFiles 'FSLogix\Apps' $frxPath = Join-Path $appsRoot 'frx.exe' $service = Get-Service -Name frxsvc -ErrorAction SilentlyContinue if ($service -and (Test-Path -LiteralPath $frxPath -PathType Leaf)) { $versionOutput = @(& $frxPath version 2>&1) -join [Environment]::NewLine return [pscustomobject]@{ Installed = $true Changed = $false RestartRequired = $false Service = $service.Status.ToString() Version = $versionOutput.Trim() } } if (-not (Test-Path -LiteralPath $InstallerPath -PathType Leaf)) { throw "FSLogixAppsSetup.exe was not found: $InstallerPath" } $resolvedInstaller = (Resolve-Path -LiteralPath $InstallerPath).Path if ([IO.Path]::GetFileName($resolvedInstaller) -ne 'FSLogixAppsSetup.exe') { throw 'InstallerPath must identify the Microsoft FSLogix core installer named FSLogixAppsSetup.exe.' } $signature = Get-AuthenticodeSignature -LiteralPath $resolvedInstaller if ($signature.Status -ne [Management.Automation.SignatureStatus]::Valid -or -not $signature.SignerCertificate -or $signature.SignerCertificate.Subject -notmatch '(^|,\s*)CN=Microsoft Corporation(,|$)') { throw 'FSLogixAppsSetup.exe must have a valid Microsoft Corporation Authenticode signature.' } $logRoot = Join-Path $env:ProgramData 'SGU\FSLogix' $logPath = Join-Path $logRoot 'install.log' if (-not $PSCmdlet.ShouldProcess($env:COMPUTERNAME, 'Install Microsoft FSLogix Apps without restarting')) { return } New-Item -ItemType Directory -Path $logRoot -Force | Out-Null $process = Start-Process -FilePath $resolvedInstaller ` -ArgumentList @('/install', '/quiet', '/norestart', '/log', "`"$logPath`"") ` -Wait -PassThru -WindowStyle Hidden if ($process.ExitCode -notin @(0, 1641, 3010)) { throw "FSLogix installation failed with exit code $($process.ExitCode). Review $logPath." } $service = Get-Service -Name frxsvc -ErrorAction SilentlyContinue if (-not $service -or -not (Test-Path -LiteralPath $frxPath -PathType Leaf)) { throw "FSLogix installation did not create the frxsvc service and frx.exe. Review $logPath." } $versionOutput = @(& $frxPath version 2>&1) -join [Environment]::NewLine [pscustomobject]@{ Installed = $true Changed = $true RestartRequired = $true Service = $service.Status.ToString() Version = $versionOutput.Trim() LogPath = $logPath }