diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..82efbf4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.*~ \ No newline at end of file diff --git a/README.md b/README.md index e778e1c..b96f1ea 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Powershell_Scripts +Divers scripts en Powershell pour faciliter l'administration des PC Windows et des serveurs \ No newline at end of file diff --git a/Windows10/ADDReg1703.ps1 b/Windows10/ADDReg1703.ps1 new file mode 100644 index 0000000..d10e3a9 --- /dev/null +++ b/Windows10/ADDReg1703.ps1 @@ -0,0 +1,40 @@ +$WimFile = "D:\TEMP\Windows10_1703\sources\install.wim" +$MountPath = “D:\TEMP\Mount” + +Mount-WindowsImage -ImagePath $WimFile -Index 1 -Path $MountPath + +#region Customise Default User Profile +Write-Output -InputObject "`nCustomising the default user profile...`n" +REG LOAD "HKLM\_USER" "$MountPath\Users\Default\NTUSER.DAT" | Out-Null +REG LOAD "HKLM\_SOFTWARE" "$MountPath\Windows\System32\config\SOFTWARE" | Out-Null + +# HKCU +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v SystemPaneSuggestionsEnabled /d 0 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v PreInstalledAppsEnabled /d 0 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" /v OemPreInstalledAppsEnabled /d 0 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v DisableThumbnailCache /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v LaunchTo /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize" /v StartupDelayInMSec /d 0 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Search" /v BingSearchEnabled /d 0 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Search" /v SearchboxTaskbarMode /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_USER\Software\Policies\Microsoft\Internet Explorer\Restrictions" /v NoHelpItemSendFeedback /d 1 /t REG_DWORD /f +& REG DELETE "HKLM\_USER\Software\Microsoft\Windows\CurrentVersion\Run" /v OneDriveSetup /f + +# HKLM +# & REG ADD "HKLM\_SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v VerboseStatus /d 1 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Internet Explorer\Main" /v DisableAddSiteMode /d 1 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\MRT" /v DontOfferThroughWUAU /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableSoftLanding /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\CloudContent" /v DisableWindowsConsumerFeatures /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\WindowsStore" /v AutoDownload /d 2 /t REG_DWORD /f +& REG ADD "HKLM\_SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsStore\WindowsUpdate" /v AutoDownload /d 2 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\Personalization" /v NoLockscreen /d 1 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\Windows Error Reporting" /v Disabled /d 1 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v AllowSearchToUseLocation /d 0 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v ConnectedSearchUseWeb /d 0 /t REG_DWORD /f +# & REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\Windows Search" /v DisableWebSearch /d 1 /t REG_DWORD /f +& REG ADD "HKLM\_SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" /v NoAutoRebootWithLoggedOnUsers /d 1 /t REG_DWORD /f + +REG UNLOAD "HKLM\_USER" | Out-Null +REG UNLOAD "HKLM\_SOFTWARE" | Out-Null +Dismount-WindowsImage -Path $MountPath -Save diff --git a/Windows10/ApplyingNET35towim1703.ps1 b/Windows10/ApplyingNET35towim1703.ps1 new file mode 100644 index 0000000..2651cef --- /dev/null +++ b/Windows10/ApplyingNET35towim1703.ps1 @@ -0,0 +1,8 @@ +$UpdatesPath = "D:\TEMP\Update\*" +$MountPath = �D:\TEMP\Mount\� +$WimFile = �D:\TEMP\Windows10_1703\sources\install.wim� +DISM /Mount-Wim /WimFile:$WimFile /index:1 /Mountdir:$MountPath +DISM /image:$MountPath /enable-feature /featurename:NetFx3 /all /limitaccess /source:F:\sources\sxs +Write-Host "Updates Applied to WIM" +DISM /Unmount-Wim /Mountdir:$MountPath /commit +DISM /Cleanup-Wim \ No newline at end of file diff --git a/Windows10/ApplyingWindowsUpdatetowim1703.ps1 b/Windows10/ApplyingWindowsUpdatetowim1703.ps1 new file mode 100644 index 0000000..0624212 --- /dev/null +++ b/Windows10/ApplyingWindowsUpdatetowim1703.ps1 @@ -0,0 +1,13 @@ +$UpdatesPath = "D:\TEMP\Update\*" +$MountPath = �D:\TEMP\Mount\� +$WimFile = �D:\TEMP\Windows10_1703\sources\install.wim� +DISM /Mount-Wim /WimFile:$WimFile /index:1 /Mountdir:$MountPath +$UpdateArray = Get-Item $UpdatesPath +ForEach ($Updates in $UpdateArray) +{ +DISM /image:$MountPath /Add-Package /Packagepath:$Updates +Start-Sleep �s 10 +} +Write-Host "Updates Applied to WIM" +DISM /Unmount-Wim /Mountdir:$MountPath /commit +DISM /Cleanup-Wim \ No newline at end of file diff --git a/Windows10/removeapps.ps1 b/Windows10/removeapps.ps1 new file mode 100644 index 0000000..acfbd2f --- /dev/null +++ b/Windows10/removeapps.ps1 @@ -0,0 +1,104 @@ +<# +.SYNOPSIS + Removing Built-in apps from Windows 10 / Windows 8.1 / Windows 8 +.DESCRIPTION + Removing Built-in apps from Windows 10 / Windows 8.1 / Windows 8 +.PARAMETER + PathtoWim - Path to install.wim + select - Enable +.EXAMPLE + .\removeapps.ps1 -pathtowim c:\10\install.wim + .\removeapps.ps1 -pathtowim c:\10\install.wim -select $true + .\removeapps.ps1 -pathtowim c:\10\install.wim -select $true -index 2 +.NOTES + Script name: removeapps.ps1 + Version: 1.2 + Author: André Picker + Contact: @clientmgmt + DateCreated: 2015-07-22 + LastUpdate: 2016-03-08 + #> + +param ( + [string]$pathtowim, + [bool]$selectapps, + [string]$index="1" + ) + +$Host.UI.RawUI.BackgroundColor = "Black"; Clear-Host +$startdate = (Get-Date).ToString() +$ProgressPreference=’SilentlyContinue’ + +function CreateTempDirectory { + $tmpDir = [System.IO.Path]::GetTempPath() + $tmpDir = [System.IO.Path]::Combine($tmpDir, [System.IO.Path]::GetRandomFileName()) + [System.IO.Directory]::CreateDirectory($tmpDir) | Out-Null + $tmpDir + } + +try { + $pathworkfolder = CreateTempDirectory + Write-Host "Start:" $startdate -ForegroundColor White + Write-Host "Create temporary directory..." -ForegroundColor Green + Write-Host "Temporary directory:" $pathworkfolder -ForegroundColor Green + } + +catch [Exception] { + Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break + } + +try { + Write-Host "Mounting Windows-Image..." $pathtowim -ForegroundColor Green + Write-Host "Please wait..." -ForegroundColor White + Mount-WindowsImage -Path $pathworkfolder -ImagePath $pathtowim -Index $index | Out-Null + } + +catch [Exception] { + Write-Host "Mounting Windows-Image failed..." -ForegroundColor Red; + Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break + } + +try { + Write-Host "Remove the following Built-in apps:" -ForegroundColor Green + $apps = Get-AppxProvisionedPackage -Path $pathworkfolder | ForEach-Object { + + if($selectapps -eq $true) { + $call = read-host "Do you really want to delete the following App:" $_.DisplayName "(Y/N)" + + if($call -eq "y") { + Write-Host "Delete:" $_.DisplayName -ForegroundColor Green + Remove-AppxProvisionedPackage -Path $pathworkfolder -PackageName $_.PackageName + $call = "" + } + + else { + Write-Host "Skipped:" $_.DisplayName -ForegroundColor yellow + } + } + + else { + Write-Host "Delete:" $_.DisplayName -ForegroundColor Green + Remove-AppxProvisionedPackage -Path $pathworkfolder -PackageName $_.PackageName + $call = "" + } + + } + } + +catch [Exception] { + Write-Host "Removing Built-in apps failed..." -ForegroundColor Red; + Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break + } + +try { + Write-Host "Dismount-WindowsImage..." -ForegroundColor Green + Write-Host "Please wait..." -ForegroundColor White + Dismount-WindowsImage -Path $pathworkfolder -Save -CheckIntegrity | Out-Null + Write-Host "Remove temporary directory..." -ForegroundColor Green + Remove-Item $pathworkfolder -Recurse -Force | Out-Null + Write-Host "Complete:" (Get-Date).ToString() -ForegroundColor White + } + +catch [Exception] { + Write-Host "Error:" $_.Exception.Message -ForegroundColor Red; break + } \ No newline at end of file