########################################################## # # InstallAndThenRemoveThunderboltControlCenter.ps1 # # A Powershell script to open the Microsoft Store to # download and install ThunderboltControlCenter and then # remove it again after installation, but leaving enough # bits behind for a GC-Titan Ridge 2.0 Thunderbolt # controller card to run on a Lenovo Thinkstation P620. # # Script by Frontinus # # # 'Use-RunAs' function to check if script was launched # in normal user mode and elevating it if necessary by # Matt Painter (Microsoft TechNet Script Center) # https://gallery.technet.microsoft.com/scriptcenter/ # # and reused from within a USBUpdate.ps1 script by Kari at # *** Twitter.com/TenForums *** Facebook.com/TenForums *** # ########################################################## ########################################################## # # Open Microsoft Store so user can download and install Thunderbolt # Control Center. # ########################################################## & "C:\Program Files\BraveSoftware\Brave-Browser\Application\brave.exe" https://www.microsoft.com/en-us/p/thunderbolt-control-center/9n6f0jv38ph1?activetab=pivot:overviewtab ########################################################## # Checking if PS is running elevated. If not, elevating it ########################################################## function Use-RunAs { # Check if script is running as Administrator and if not elevate it # Use Check Switch to check if admin param([Switch]$Check) $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()` ).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") if ($Check) { return $IsAdmin } if ($MyInvocation.ScriptName -ne "") { if (-not $IsAdmin) { try { $arg = "-file `"$($MyInvocation.ScriptName)`"" Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop' } catch { Write-Warning "Error - Failed to restart script elevated" break } exit } } } Use-RunAs ################################################################### # # Pause for the user to confirm that they have installed # Thunderbolt Control Center. # # Pause function copied from https://stackoverflow.com/questions/3963100/how-do-you-do-a-pause-with-powershell-2-0 # ################################################################### Read-Host -Prompt "Once Thunderbolt Control Center has been installed, launch it, and unplug and replug the Thunderbolt drive or device so that Thunderbolt Control Center recognises it. Then press any key to uninstall it again and reboot . . . " # Remove the Thunderbolt Control Center software get-appxpackage *thunder* |remove-appxpackage # Reboot Restart-Computer