Update 4.1.8/4.1.8-Command-Examples.ps1

This commit is contained in:
2026-03-22 13:44:52 +00:00
parent e3bfd64529
commit 9a75633d70

View File

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