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

@@ -29,11 +29,7 @@ foreach ($fileInfo in $filesToDownload) {
}
# Install Office
function Check-OfficeInstall {
param (
[string] $version = "Office365" # Specify the Office version (e.g., "Office365" or "2019")
)
function CheckOfficeInstall {
$officeRegistryPath = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun"
if (Test-Path -Path $officeRegistryPath) {
$installedPath = Get-ItemProperty -Path $officeRegistryPath | Select-Object -ExpandProperty "InstallPath"
@@ -57,13 +53,14 @@ function Check-OfficeInstall {
Start-Process -FilePath $(Join-Path $driveLetter '\Office\Setup64.exe') -Wait
}
}
CheckOfficeInstall
# Activate windows/office
irm https://massgrave.dev/get | iex
Invoke-RestMethod https://massgrave.dev/get | Invoke-Expression
# Setup users
$username = "Eleve"
if ($(Get-LocalUser -Name $username -ErrorAction SilentlyContinue) -eq $null) {
if ($null -eq $(Get-LocalUser -Name $username -ErrorAction SilentlyContinue)) {
Write-Host "User $username doesn't exist. Creating the user..."
New-LocalUser -Name $username -Description "New User Account" -NoPassword -UserMayNotChangePassword
Add-LocalGroupMember -Group Users -Member $username
@@ -73,7 +70,7 @@ if ($(Get-LocalUser -Name $username -ErrorAction SilentlyContinue) -eq $null) {
}
$username = "Prof"
$SecurePassword = ConvertTo-SecureString -String "IPRprof2398" -AsPlainText -Force
if ($(Get-LocalUser -Name $username -ErrorAction SilentlyContinue) -eq $null) {
if ($null -eq $(Get-LocalUser -Name $username -ErrorAction SilentlyContinue)) {
Write-Host "User $username doesn't exist. Creating the user..."
New-LocalUser -Name $username -Description "New User Account" -Password $SecurePassword -PasswordNeverExpires -UserMayNotChangePassword
Add-LocalGroupMember -Group Users -Member $username
@@ -83,7 +80,7 @@ if ($(Get-LocalUser -Name $username -ErrorAction SilentlyContinue) -eq $null) {
}
$username = "Admin"
$SecurePassword = ConvertTo-SecureString -String "Lprsnm4ehk26-" -AsPlainText -Force
if ($(Get-LocalUser -Name $username -ErrorAction SilentlyContinue) -eq $null) {
if ($null -eq $(Get-LocalUser -Name $username -ErrorAction SilentlyContinue)) {
Write-Host "User $username doesn't exist. Creating the user..."
New-LocalUser -Name $username -Description "New User Account" -Password $SecurePassword -PasswordNeverExpires -UserMayNotChangePassword
Add-LocalGroupMember -Group Administrators -Member $username
@@ -100,7 +97,7 @@ function UserReg {
)
$UserProfiles = Get-WmiObject Win32_UserProfile | Where-Object { $_.Special -eq $false }
$UserProfile = $UserProfiles | Where-Object { $_.LocalPath.EndsWith("\$Username") }
if ($UserProfile -ne $null) {
if ($null -ne $UserProfile) {
$UserSID = $UserProfile.SID
if( -not (Test-Path -Path "Registry::HKEY_USERS\$UserSID" -PathType Container) ) {
REG LOAD HKEY_USERS\$UserSID "C:\Users\$Username\NTUSER.DAT"
@@ -134,7 +131,7 @@ function SetRegistry {
$UserSID, $UserHKUPath = UserReg -Username "Eleve"
# Add restriction
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"
@@ -157,7 +154,7 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) {
if (-not (Test-Path -Path "Registry::$DisallowRunPath" -PathType Container)) {
New-Item -Path $DisallowRunPath -Force
}
Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1
Set-ItemProperty -Path $DisallowRunKeyPath -Name $DisallowRunValueName -Value 1
$applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe")
Get-ItemProperty -Path $DisallowRunPath | ForEach-Object {
Remove-ItemProperty -Path $DisallowRunPath -Name $_.PSObject.Properties.Name -ErrorAction SilentlyContinue
@@ -202,7 +199,6 @@ function InstallExe {
if (-not (Test-Path -Path $targetPath -PathType Container)) {
New-Item -Path $targetPath -ItemType Directory
}
$appFilePath = Join-Path $tmpPath $app
Copy-Item -Path (Join-Path $tmpPath $app) -Destination $targetPath -Force
createShortcut -exe (Join-Path $targetPath $app) -app $appName
}
@@ -247,7 +243,7 @@ function createShortcut {
}
#Install Choco
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'))
# Installing needed apps
choco upgrade all -y
@@ -271,7 +267,7 @@ InstallMsi -app "EV3_Classroom_Windows_1.5.3_Global.msi"
InstallZip -zip "RobotProg.zip" -exe "RobotProg.exe" -app "RobotProg"
# URL shortcut
function Create-DesktopShortcut {
function New-DesktopShortcut {
param (
[string] $ShortcutName,
[string] $TargetUrl
@@ -285,10 +281,10 @@ function Create-DesktopShortcut {
$urlShortcut.Save()
}
Create-DesktopShortcut -ShortcutName "Office 365" -TargetUrl "https://office.com/"
Create-DesktopShortcut -ShortcutName "Ecole Direct" -TargetUrl "https://ecoledirecte.com/"
Create-DesktopShortcut -ShortcutName "PIX" -TargetUrl "https://pix.fr/"
Create-DesktopShortcut -ShortcutName "Framindmap" -TargetUrl "https://framindmap.org/"
New-DesktopShortcut -ShortcutName "Office 365" -TargetUrl "https://office.com/"
New-DesktopShortcut -ShortcutName "Ecole Direct" -TargetUrl "https://ecoledirecte.com/"
New-DesktopShortcut -ShortcutName "PIX" -TargetUrl "https://pix.fr/"
New-DesktopShortcut -ShortcutName "Framindmap" -TargetUrl "https://framindmap.org/"
# Update Windows