Fix scripts

This commit is contained in:
2023-10-23 16:33:08 +00:00
parent e333365da4
commit b76e612f35
3 changed files with 31 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
# remove bloatware
$apps = @(
"Microsoft.549981C3F5F10"
@@ -204,9 +204,9 @@ Set-LocalUser -Name "Prof" -PasswordNeverExpires $true -UserMayChangePassword $f
$SecurePassword = ConvertTo-SecureString -String "Lprsnm4ehk26-" -AsPlainText -Force
Set-LocalUser -Name "Admin" -PasswordNeverExpires $true -Password $SecurePassword
cd D:\Setup\Labo
cd E:\Setup\Labo
cd F:\Setup\Labo
Set-Location D:\Setup\Labo
Set-Location E:\Setup\Labo
Set-Location F:\Setup\Labo
Copy-Item -Path .\Software\* -Destination "C:\Program Files\" -Recurse
Copy-Item -Path .\Shortcut\* -Destination "C:\Users\Public\Desktop\" -Recurse
icacls "C:\Users\Public" /grant:r "Eleve:(OI)(CI)(R)"
@@ -225,11 +225,9 @@ function UserReg {
$UserProfile = $UserProfiles | Where-Object { $_.LocalPath.EndsWith("\$Username") }
# Check if the user profile exists
if ($UserProfile -ne $null) {
if ($null -ne $UserProfile) {
# Construct the path to the user's NTUSER.DAT file (registry hive)
$UserSID = $UserProfile.SID
$HivePath = Join-Path -Path $UserProfile.LocalPath -ChildPath "NTUSER.DAT"
# Return the user's SID and HKU registry key
return $UserSID, "Registry::HKEY_USERS\$UserSID"
} else {
@@ -241,7 +239,7 @@ function UserReg {
$TargetUsername = "Eleve"
$UserSID, $UserHKUPath = UserReg -Username $TargetUsername
if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
if ($null -ne $UserSID -and $null -ne $UserHKUPath) {
# Restrict access to Settings
$ControlPanelKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"
$ControlPanelValueName = "NoControlPanel"