<# Fold Ctrl+K Ctrl+0 Unfold Ctrl+K Ctrl+J PSADT 4.1.x Compatible Commands #> ##*=============================================== ##* PRE-INSTALLATION ##*=============================================== #Region Close applications before proceeding Show-ADTInstallationWelcome -CloseProcesses 'mBlock','msedge' -BlockExecution -CloseProcessesCountdown 1800 -NotTopMost Show-ADTInstallationWelcome -CloseProcesses 'mBlock','msedge' -BlockExecution -AllowDeferCloseProcesses -DeferTimes 5 -DeferDays 2 -ForceCloseProcessesCountdown 1800 -PersistPrompt -NotTopMost #EndRegion ##*=============================================== ##* INSTALLATION ##*=============================================== #Region Download content $ProgressPreference = 'SilentlyContinue' Invoke-WebRequest -Uri "https://toronenintuneblob.blob.core.windows.net/intuneapp/file.zip" -OutFile "$($env:PUBLIC)\Desktop\file.zip" #Endregion #Region Expand-Archive Expand-Archive -LiteralPath "$($env:PUBLIC)\Desktop\file.zip" -DestinationPath "$($env:PUBLIC)\Desktop\Expanded" Expand-Archive -Path "$($adtSession.DirFiles)\FyiFile.zip" -DestinationPath "C:\Path" #Endregion #Region Unzip installation source files to a temp folder with 7-Zip standalone Start-ADTProcess -FilePath "$($adtSession.DirSupportFiles)\7za.exe" -ArgumentList "x `"$($adtSession.DirFiles)\source.zip`" -o`"$envProgramFiles\SWTEMP`" -y" #EndRegion #Region Install Microsoft 365 apps and Teams If (((Get-WmiObject Win32_ComputerSystem).Model -eq "VMware Virtual Platform") -or ((Get-WmiObject Win32_ComputerSystem).Model -eq "Virtual Machine") -or ((Get-WmiObject Win32_ComputerSystem).Model -eq "VirtualBox")){ #Optimize Teams for VDI Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Microsoft\Teams" -Name "IsWVDEnvironment" -Value "1" -Type "DWord" #Install Microsoft 365 desktop apps for multi-session host Start-ADTProcess -FilePath "$($adtSession.DirFiles)\setup.exe" -ArgumentList "/configure `"$($adtSession.DirFiles)\Install-multisession.xml`"" -WindowStyle Hidden -WaitForMsiExec #Install Visual C++ Redistributables Start-ADTProcess -FilePath 'vc_redist.x64.exe' -ArgumentList '/quiet /norestart' -WindowStyle Hidden -IgnoreExitCodes "1638" #Install WebRTC Service Start-ADTMsiProcess -Action 'Install' -FilePath 'MsRdcWebRTCSvc_HostSetup_1.45.2310.13001_x64.msi' -AdditionalArgumentList '/QN' #Install Microsoft Edge WebView2 Start-ADTProcess -FilePath 'MicrosoftEdgeWebview2Setup.exe' -ArgumentList '/silent /install' -WindowStyle Hidden } Else{ #Install Microsoft 365 desktop apps for single-session host Start-ADTProcess -FilePath "$($adtSession.DirFiles)\setup.exe" -ArgumentList "/configure `"$($adtSession.DirFiles)\Install-singlesession.xml`"" -WindowStyle Hidden -WaitForMsiExec } #EndRegion #Install Microsoft Teams Start-ADTProcess -FilePath "teamsbootstrapper.exe" -ArgumentList "-p" #EndRegion #Region Run MSI installer Start-ADTMsiProcess -Action "Install" -FilePath "setup.msi" Start-ADTMsiProcess -Action "Install" -FilePath "setup.msi" -AdditionalArgumentList "AUTO_UPDATE=2","NOTINSTALLUPDATE=0" Start-ADTMsiProcess -Action "Install" -FilePath "setup.msi" -AdditionalArgumentList "AUTO_UPDATE=2","NOTINSTALLUPDATE=0" -ArgumentList '/qn' Start-ADTMsiProcess -Action "Install" -FilePath "setup.msi" -Transforms "transforms.mst" -AdditionalArgumentList "AUTO_UPDATE=2","NOTINSTALLUPDATE=0" -ArgumentList '/qn' #EndRegion #Region Run MSP patch Start-ADTMspProcess -FilePath 'AcroRdr2017Upd1701130143_MUI.msp' -AdditionalArgumentList 'ALLUSERS=1' #EndRegion #Region Run EXE #Run InstallShield process and record .ISS answer file. The answer file will be created in C:\Windows folder Start-ADTProcess -FilePath "Setup.exe" -ArgumentList "/r" -IgnoreExitCodes '*' -WindowStyle Hidden Start-Process -FilePath "$($adtSession.DirFiles)\SETUP.EXE" -ArgumentList "/r" -Wait -WindowStyle Hidden -EA 0 #Run InstallShield process with .ISS answer file Start-ADTProcess -FilePath "Setup.exe" -ArgumentList "/s /f1`"$($adtSession.DirFiles)\setup.iss`" /f2`"C:\Windows\InstallSetup.log`"" -IgnoreExitCodes '1000,1001,*' -WindowStyle Hidden Start-Process -FilePath "C:\Program Files (x86)\InstallShield Installation Information\{EC0EFF2F-1EDE-407C-A025-C4474E42B067}\SETUP.EXE" -ArgumentList "/s /f1`"$($adtSession.DirFiles)\setup.iss`"" -Wait -WindowStyle Hidden -EA 0 Start-Process -FilePath "$($adtSession.DirFiles)\SETUP.EXE" -ArgumentList "/s /f1`"$($adtSession.DirFiles)\setup.iss`"" -Wait -WindowStyle Hidden -EA 0 #Run EXE installer Start-Process -FilePath "$($adtSession.DirFiles)\CADMATIC_Draw_2024T1R2_FIN.exe" -ArgumentList "/userdata `"$($adtSession.DirFiles)\UserData.dat`" /activationkey 10395-69014-52815-95927 /DEFAULT /SILENT" -Wait -WindowStyle Hidden -EA 0 Start-ADTProcess -FilePath "Setup.exe" -ArgumentList "/r" -IgnoreExitCodes '*' -WindowStyle Hidden #EndRegion #Region Run Appx installers #User account Add-AppxPackage -Path "$($adtSession.DirFiles)\MicrosoftCorporationII.Windows365_1.3.241.0_x64__8wekyb3d8bbwe.Msix" -DependencyPath "$($adtSession.DirFiles)\Microsoft.VCLibs.140.00_14.0.33519.0_x64__8wekyb3d8bbwe.Appx","$($adtSession.DirFiles)\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33519.0_x64__8wekyb3d8bbwe.Appx" #Device provisioning (install dependencies first) Add-AppxProvisionedPackage -Online -PackagePath "$($adtSession.DirFiles)\Microsoft.VCLibs.140.00_14.0.33519.0_x64__8wekyb3d8bbwe.Appx" -SkipLicense Add-AppxProvisionedPackage -Online -PackagePath "$($adtSession.DirFiles)\Microsoft.VCLibs.140.00.UWPDesktop_14.0.33519.0_x64__8wekyb3d8bbwe.Appx" -SkipLicense Add-AppxProvisionedPackage -Online -PackagePath "$($adtSession.DirFiles)\MicrosoftCorporationII.Windows365_1.3.241.0_x64__8wekyb3d8bbwe.Msix" -SkipLicense #Device provisioning, check if package already exists (install dependencies first) $AppxName = "MicrosoftCorporationII.Windows365" $TestAppx = Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -eq $AppxName} if(!($TestAppx)){ Add-AppxProvisionedPackage -Online -PackagePath "$($adtSession.DirFiles)\MicrosoftCorporationII.Windows365_1.3.241.0_x64__8wekyb3d8bbwe.Msix" -SkipLicense } #EndRegion #Region Run PowerShell script Start-ADTProcess -FilePath "powershell.exe" -ArgumentList "-Command & { & `"$($adtSession.DirFiles)\ConfigureSEMM.ps1`"; Exit `$LastExitCode }" #Endregion #Region Execute process as logged in user Start-ADTProcessAsUser -FilePath "$PSHOME\powershell.exe" -ArgumentList "-Command & { & `"C:\Test\Script.ps1`"; Exit `$LastExitCode }" Start-ADTProcessAsUser -FilePath "$envProgramFiles\Microsoft OneDrive\OneDrive.exe" -ArgumentList "/background" Start-ADTProcessAsUser -FilePath "$envProgramFiles\DesktopInfo\DesktopInfo64.exe" #Endregion #Region Wait until process has closed #Process name in this example is "setup" do{ Start-Sleep -Seconds 3 } until (!(Get-Process setup -EA 0)) #Endregion #Region Modify files and folders #Create folder New-ADTFolder -Path "C:\Windows\STWindowsRestart" #Create a folder if it does not exist if(!(Test-Path "C:\Windows\MasterCam2024Setup")){ New-ADTFolder -Path "C:\Windows\MasterCam2024Setup" } #Remove folder Remove-ADTFolder -Path 'C:\Windows\STWindowsRestart' #Copy files Copy-ADTFile -Path "$($adtSession.DirFiles)\*" -Destination "C:\Windows\STWindowsRestart" -Recurse #Remove file Remove-ADTFile -Path 'C:\eula.1028.txt' #EndRegion #Region Add new lines to text file Add-Content -Path "C:\ProgramData\CADMATIC\Draw 24\CadsSetup.ini" -Value "CadsnetHost=uksrv2" -Force Add-Content -Path "C:\ProgramData\CADMATIC\Draw 24\CadsSetup.ini" -Value "[Automaattipäivitys]" -Force Add-Content -Path "C:\ProgramData\CADMATIC\Draw 24\CadsSetup.ini" -Value "Estetty=1333" -Force #Endregion #Region add content to hosts file $File = "C:\Windows\System32\drivers\etc\hosts" $Hostfile = Get-Content $File $Hostfile += "10.0.12.87 sopronet.fyi.fi campus.fyi.fi study.fyi.fi" Set-Content -Path $File -Value $Hostfile -Force #Endregion #Region Certificates <# Certificate stores: Root "Trusted Root Certification Authorities" Trust "Enterprise Trust" CA "Intermediate Certification Authorities" TrustedPublisher "Trusted Publishers" Disallowed "Untrusted Certificates" AuthRoot "Third-Party Root Certification Authorities" TrustedPeople "Trusted People" ClientAuthIssuer "Client Authentication Issuers" FlightRoot "Preview Build Roots" TestSignRoot "Test Roots" OemEsim "OEM eSIM Certification Authorities" PasspointTrustedRoots "Passpoint Trusted Roots" SmartCardRoot "Smart Card Trusted Roots" TrustedAppRoot "Trusted Packaged App Installation Authorities" TrustedDevices "Trusted Devices" #> Start-ADTProcess -FilePath "certutil.exe" -ArgumentList "-f -addstore -enterprise TrustedPublisher `"$($adtSession.DirFiles)\0a8b99555bf112ee6166825f03cbc3ed.cer`"" Start-ADTProcess -FilePath "certutil.exe" -ArgumentList "-f -addstore -enterprise Root `"$($adtSession.DirFiles)\13d193a1.0.crt`"" #Install Trusted People Certificate function Import-PfxCertificate { param([String]$certPath,[String]$certRootStore = "localmachine",[String]$certStore = "My",$pfxPass = $null) $pfx = new-object System.Security.Cryptography.X509Certificates.X509Certificate2 if ($pfxPass -eq $null){ $pfxPass = "JokuSalasana" } $pfx.import($certPath,$pfxPass,"Exportable,PersistKeySet") $store = new-object System.Security.Cryptography.X509Certificates.X509Store($certStore,$certRootStore) $store.open("MaxAllowed") $store.add($pfx) $store.close() } Import-PfxCertificate "$($adtSession.DirFiles)\MSIX.pfx" "LocalMachine" "TrustedPeople" #Remove Certificates Start-ADTProcess -FilePath "certutil.exe" -ArgumentList "-f -delstore -enterprise Root `"edcdb4651c35feba0c0912b14c449112dbb9e8bc`"" #EndRegion #Region Modify DLL modules Register-ADTDll -FilePath "$($adtSession.DirFiles)\example\codec.dll" Unregister-ADTDll -FilePath "$envProgramFilesX86\Vendor\App\Temeletry.dll" #Endregion #Region Install INF drivers Get-ChildItem "$($adtSession.DirFiles)" -Recurse -Filter "*inf" | ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install } #Endregion #Region Modify file or folder ACL #Modify ACL on a file #first load the ACL $acl_to_modify = "$envProgramData\Example\File.txt" $acl = Get-Acl "$acl_to_modify" #add another entry to the ACL list (in this case, add all users to have full control) $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Users", "FullControl", "None", "None", "Allow") $acl.SetAccessRule($ar) #re-write the acl on the target file Set-Acl "$acl_to_modify" $acl #Modify ACL on a folder $folder_to_change = "$envSystemDrive\Example_Folder" $acl = Get-Acl "$folder_to_change" $ar = New-Object System.Security.AccessControl.FileSystemAccessRule("BUILTIN\Users", "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow") $acl.SetAccessRule($ar) Set-Acl "$folder_to_change" $acl #Endregion #Region Set registry permissions Start-ADTProcess -FilePath "$($adtSession.DirSupportFiles)\SetACL.exe" -ArgumentList '-on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn setowner -ownr "n:SYSTEM"' -WindowStyle 'Hidden' Start-ADTProcess -FilePath "$($adtSession.DirSupportFiles)\SetACL.exe" -ArgumentList '-on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Communications" -ot reg -actn ace -ace "n:SYSTEM;p:full"' -WindowStyle 'Hidden' #Endregion #Region Modify registry keys for local machine Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Policies\Google\Chrome" -Name 'ShowHomeButton' -Type 'Dword' -Value '1' #Remove registry keys or values for local machine Remove-ADTRegistryKey -Key "HKLM:\SOFTWARE\Policies\Google\Chrome" -Recurse Remove-ADTRegistryKey -Key "HKLM:\SOFTWARE\Policies\Google\Chrome" -Name 'ShowHomeButton' #EndRegion #Region Modify registry keys for all users #Set registry keys for all users [scriptblock]$HKCURegistrySettingsInstall = { Set-ADTRegistryKey -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'Hidden' -Value 1 -Type DWord -SID $UserProfile.SID Set-ADTRegistryKey -Key 'HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced' -Name 'HideFileExt' -Value 0 -Type DWord -SID $UserProfile.SID } Invoke-ADTAllUsersRegistryAction -ScriptBlock $HKCURegistrySettingsInstall #Remove registry keys for all users [scriptblock]$HKCURegistrySettingsUninstall = { Remove-ADTRegistryKey -Key 'HKCU\SOFTWARE\Policies\Google\Chrome' -Name 'ShowHomeButton' -SID $UserProfile.SID Remove-ADTRegistryKey -Key 'HKCU\SOFTWARE\Policies\Google\Chrome' -Recurse -SID $UserProfile.SID } Invoke-ADTAllUsersRegistryAction -ScriptBlock $HKCURegistrySettingsUninstall #EndRegion #Region Clear Teams cache for logged on user $loggedonUser = Get-ADTLoggedOnUser | Select-Object -ExpandProperty UserName $TeamsPath = [System.IO.Path]::Combine('C:\Users\', $loggedonUser,'Appdata', 'Roaming', 'Microsoft', 'Teams') Remove-ADTFile -Path "$TeamsPath\Cache\*" #EndRegion #Region Set lock screen wallpaper Copy-ADTFile -Path "$($adtSession.DirFiles)\Strategiakuva_Lukitusnaytto_4K.jpg" -Destination "C:\Windows\Strategiakuva_Lukitusnaytto_4K.jpg" Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP" -Name "LockScreenImagePath" -Value "C:\Windows\Strategiakuva_Lukitusnaytto_4K.jpg" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP" -Name "LockScreenImageStatus" -Value 1 -Type DWORD Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PersonalizationCSP" -Name "LockScreenImageUrl" -Value "C:\Windows\Strategiakuva_Lukitusnaytto_4K.jpg" -Type String RUNDLL32.EXE USER32.DLL, UpdatePerUserSystemParameters 1, True #Endregion #Region Enable Windows features $HyperVActive = Get-WindowsOptionalFeature -Online -FeatureName *Hyper-V-All* if($HyperVActive.State -ne "Enabled"){ Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All -NoRestart } #Endregion #Region Inject drivers to WinRE $MountDir = "$env:SystemDrive\WinRE" if (!(Test-Path -Path $MountDir)) { New-Item -Path $MountDir -ItemType Directory } ReAgentC.exe /mountre /path $MountDir dism /Image:$MountDir /Add-Driver /Driver:$($adtSession.DirFiles) /recurse dism /Image:$MountDir /Cleanup-Image /StartComponentCleanup ReAgentc.exe /unmountre /path $MountDir /commit Remove-Item -Path $MountDir #Endregion #Region Set firewall rules #Allow through Firewall - allow private, domain but block public if (Get-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)"){ Remove-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)" } if (Get-NetFirewallRule -DisplayName "Block $($adtSession.AppName)"){ Remove-NetFirewallRule -DisplayName "Block $($adtSession.AppName)" } New-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)" -Direction Inbound -Program "$envProgramFiles\Makeblock\mBlock\mBlock.exe" -LocalPort Any -Protocol TCP -Action Allow -Enabled True -Profile Domain,Private New-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)" -Direction Inbound -Program "$envProgramFiles\Makeblock\mBlock\mBlock.exe" -LocalPort Any -Protocol UDP -Action Allow -Enabled True -Profile Domain,Private New-NetFirewallRule -DisplayName "Block $($adtSession.AppName)" -Direction Inbound -Program "$envProgramFiles\Makeblock\mBlock\mBlock.exe" -LocalPort Any -Protocol TCP -Action Block -Enabled True -Profile Public New-NetFirewallRule -DisplayName "Block $($adtSession.AppName)" -Direction Inbound -Program "$envProgramFiles\Makeblock\mBlock\mBlock.exe" -LocalPort Any -Protocol UDP -Action Block -Enabled True -Profile Public #EndRegion #Region Create and remove public desktop shortcuts if(!(Test-Path "C:\Users\Public\Desktop\PowerShell.lnk" -PathType Leaf)){ $WScriptObj = New-Object -ComObject ("WScript.Shell") $shortcut = $WscriptObj.CreateShortcut("C:\Users\Public\Desktop\PowerShell.lnk") $shortcut.TargetPath = "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" $shortcut.IconLocation= "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" $shortcut.Save() } #Remove public desktop shortcut Remove-ADTFile -Path "$envCommonDesktop\mBlock.lnk" #EndRegion #Region Add M-Files vault # M-Files Vault 1 If (Test-Path "$env:ProgramFiles\M-Files\*\Bin\x64\MFStatus.exe"){ $Versio = Resolve-Path "$env:ProgramFiles\M-Files\*\Bin\x64\MFStatus.exe" | Select-Object -ExpandProperty Path $AsennettuVersio = $Versio.split('\')[3] Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'AuthType' -Value 1 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'AutoLogin' -Value 0 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'Endpoint' -Value "2266" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'HTTPProxy' -Value "" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'ID' -Value 1 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'InfoTip' -Value "Browse to this folder to view the contents of this document vault." -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'NetworkAddress' -Value "MFiles01" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'ProtocolSequence' -Value "ncacn_ip_tcp" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'Secured' -Value 0 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'ServerVaultGUID' -Value "{EC4EE1AA-FAF9-4A5E-9882-0110E4224531}" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'ServerVaultName' -Value "Company" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$AsennettuVersio\Client\MFClient\Vaults\Company" -Name 'SPN' -Value "" -Type String #Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\$AsennettuVersio\Client\MFClient" -Name 'ApproveEachApplicationSeparately' -Value "0" -Type Dword } Else{ Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'AuthType' -Value 1 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'AutoLogin' -Value 0 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'Endpoint' -Value "2266" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'HTTPProxy' -Value "" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'ID' -Value 1 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'InfoTip' -Value "Browse to this folder to view the contents of this document vault." -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'NetworkAddress' -Value "MFiles01" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'ProtocolSequence' -Value "ncacn_ip_tcp" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'Secured' -Value 0 -Type Dword Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'ServerVaultGUID' -Value "{EC4EE1AA-FAF9-4A5E-9882-0110E4224531}" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'ServerVaultName' -Value "Company" -Type String Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\M-Files\$($adtSession.AppVersion)\Client\MFClient\Vaults\Company" -Name 'SPN' -Value "" -Type String #Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\Motive\$($adtSession.AppVersion)\Client\MFClient" -Name 'ApproveEachApplicationSeparately' -Value "0" -Type Dword } #EndRegion ##*=============================================== ##* POST-INSTALLATION ##*=============================================== #Region Set registry value after successful installation Set-ADTRegistryKey -Key "HKLM:\SOFTWARE\$($adtSession.AppScriptAuthor)\$($adtSession.AppVendor)\$($adtSession.AppName)\$($adtSession.AppVersion)" -Name 'Installed' -Type 'String' -Value '1' #EndRegion #Region Force restart after installation Show-ADTInstallationRestartPrompt -Countdownseconds 120 -CountdownNoHideSeconds 60 #EndRegion ##*=============================================== ##* PRE-UNINSTALLATION ##*=============================================== #Region Close applications before proceeding Show-ADTInstallationWelcome -CloseProcesses 'mBlock','msedge' -BlockExecution -CloseProcessesCountdown 1800 -NotTopMost #Endregion ##*=============================================== ##* UNINSTALLATION ##*=============================================== ## #Region Remove MSI application Uninstall-ADTApplication -Name 'mBlock' #Endregion #Region Run Appx uninstaller #User account 1 Remove-AppxPackage package1_1.0.0.0_neutral__8wekyb3d8bbwe #PackageName #User account 2 $AppPackageName1 = "MicrosoftCorporationII.Windows365" $PackageName = Get-AppxPackage | Where-Object {$_.Name -eq $AppPackageName1} $AppxFullName = $PackageName.PackageFullName | Remove-AppxPackage #System wide $AppPackageName = "MicrosoftCorporationII.Windows365" $PackageName = Get-AppxProvisionedPackage -Online | Where-Object {$_.DisplayName -eq $AppPackageName} $PackageName.PackageName Remove-AppxProvisionedPackage -PackageName $PackageName.PackageName -AllUsers -Online #EndRegion #Region Remove Trusted Publisher Certificate Start-ADTProcess -FilePath "certutil.exe" -ArgumentList "-f -delstore -enterprise TrustedPublisher `"0a8b99555bf112ee6166825f03cbc3ed`"" #Endregion #Region Remove Firewall rule if (Get-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)"){ Remove-NetFirewallRule -DisplayName "Allow $($adtSession.AppName)" } if (Get-NetFirewallRule -DisplayName "Block $($adtSession.AppName)"){ Remove-NetFirewallRule -DisplayName "Block $($adtSession.AppName)" } #Endregion #Region Delete desktop shortcut Remove-ADTFile -Path "$envCommonDesktop\mBlock.lnk" -EA 0 #Endregion ##*=============================================== ##* POST-UNINSTALLATION ##*=============================================== ## #Region Remove registry value after successful uninstallation Remove-ADTRegistryKey -Key "HKLM:\SOFTWARE\$($adtSession.AppScriptAuthor)\$($adtSession.AppVendor)\$($adtSession.AppName)" -Recurse #EndRegion