<# .SYNOPSIS OSDCloud Start Script .DESCRIPTION https://osd.psp.osdcloud.ch .NOTES Version: 0.1 Creation Date: 05.03.2024 Author: Ákos Bakos Company: SmartCon GmbH Contact: akos.bakos@smartcon.ch Copyright (c) 2024 SmartCon GmbH HISTORY: Date By Comments ---------- --- ---------------------------------------------------------- 18.07.2023 Ákos Bakos Script created 08.03.2024 Ákos Bakos Define password for start 03.04.2025 Cyrill Schaffner Change to 23H2 19.11.2025 Jonathan Arlt Change to 24H2 02.07.2026 Cyrill Schaffner Change to 25H2 #> Function Start-PSPOSD { #================================================ # [PreOS] Update Module #================================================ Write-Host -ForegroundColor Green "Updating OSD PowerShell Module" Install-Module OSD -Force Write-Host -ForegroundColor Green "Importing OSD PowerShell Module" Import-Module OSD -Force #======================================================================= # [OS] Params and Start-OSDCloud #======================================================================= $Params = @{ OSVersion = "Windows 11" OSBuild = "25H2" OSEdition = "Pro" OSLanguage = "de-de" OSLicense = "Retail" ZTI = $true Firmware = $true } Start-OSDCloud @Params #================================================ # [PostOS] OOBEDeploy Configuration #================================================ Write-Host -ForegroundColor Green "Create C:\ProgramData\OSDeploy\OSDeploy.OOBEDeploy.json" $OOBEDeployJson = @' { "AddNetFX3": { "IsPresent": true }, "Autopilot": { "IsPresent": false }, "RemoveAppx": [ "Clipchamp.Clipchamp", "Microsoft.549981C3F5F10", "Microsoft.BingNews", "Microsoft.BingWeather", "Microsoft.GamingApp", "Microsoft.GetHelp", "Microsoft.Getstarted", "Microsoft.MicrosoftOfficeHub", "Microsoft.MicrosoftSolitaireCollection", "Microsoft.Paint", "Microsoft.People", "Microsoft.PowerAutomateDesktop", "Microsoft.StorePurchaseApp", "Microsoft.Todos", "microsoft.windowscommunicationsapps", "Microsoft.WindowsFeedbackHub", "Microsoft.WindowsMaps", "Microsoft.WindowsSoundRecorder", "Microsoft.Xbox.TCUI", "Microsoft.XboxGameCallableUI", "Microsoft.XboxGameOverlay", "Microsoft.XboxGamingOverlay", "Microsoft.XboxIdentityProvider", "Microsoft.XboxSpeechToTextOverlay", "Microsoft.YourPhone", "Microsoft.ZuneMusic", "Microsoft.ZuneVideo", "MicrosoftTeams" ], "UpdateDrivers": { "IsPresent": true }, "UpdateWindows": { "IsPresent": true } } '@ If (!(Test-Path "C:\ProgramData\OSDeploy")) { New-Item "C:\ProgramData\OSDeploy" -ItemType Directory -Force | Out-Null } $OOBEDeployJson | Out-File -FilePath "C:\ProgramData\OSDeploy\OSDeploy.OOBEDeploy.json" -Encoding ascii -Force #================================================ # [PostOS] Define Autopilot Attributes #================================================ Write-Host -ForegroundColor Green "Define Computername" $HW = $NULL $ChassisType = (Get-WmiObject -Query "SELECT * FROM Win32_SystemEnclosure").ChassisTypes $HyperV = Get-WmiObject -Query "SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE '%Microsoft Corporation%' AND Model LIKE '%Virtual Machine%'" $VMware = Get-WmiObject -Query "SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE '%VMware%' AND Model LIKE '%VMware%'" $RandomNumber = Get-Random -Minimum 0001 -Maximum 9999 $formattedNumber = "{0:D4}" -f $RandomNumber If ($HyperV -or $VMware) { $HW = "VM" } If ($ChassisType -eq "8" -or ` $ChassisType -eq "9" -or ` $ChassisType -eq "10" -or ` $ChassisType -eq "11" -or ` $ChassisType -eq "12" -or ` $ChassisType -eq "14" -or ` $ChassisType -eq "18" -or ` $ChassisType -eq "21" -or ` $ChassisType -eq "31") { $HW = "NB" } elseif ($ChassisType -eq "3" -or ` $ChassisType -eq "4" -or ` $ChassisType -eq "5" -or ` $ChassisType -eq "6" -or ` $ChassisType -eq "7" -or ` $ChassisType -eq "15" -or ` $ChassisType -eq "16") { $HW = "WS" } If (!($HW)) { $AssignedComputerName = "RENAMEME$formattedNumber" } else { $AssignedComputerName = "PSP$HW$formattedNumber" } Write-Host -ForegroundColor Green "Define Computername" If ($HyperV -or $VMware) { $AddToGroup = "G_ORG_Autopilot_Devices_VM" $GroupTag = "AutopilotVM" } else { $AddToGroup = "G_ORG_Autopilot_Devices" $GroupTag = "AutopilotHW" } Write-Host -ForegroundColor Red "Computername: $AssignedComputerName" Write-Host -ForegroundColor Red "AddToGroup: $AddToGroup" Write-Host -ForegroundColor Red "GroupTag: $GroupTag" #================================================ # [PostOS] AutopilotOOBE Configuration #================================================ Write-Host -ForegroundColor Green "Create C:\ProgramData\OSDeploy\OSDeploy.AutopilotOOBE.json" $AutopilotOOBEJson = @" { "AssignedComputerName" : "$AssignedComputerName", "AddToGroup": "$AddToGroup", "Assign": { "IsPresent": true }, "GroupTag": "$GroupTag", "Hidden": [ "AddToGroup", "AssignedUser", "PostAction", "GroupTag", "Assign" ], "PostAction": "Quit", "Run": "NetworkingWireless", "Docs": "https://google.com/", "Title": "Autopilot Manual Register" } "@ If (!(Test-Path "C:\ProgramData\OSDeploy")) { New-Item "C:\ProgramData\OSDeploy" -ItemType Directory -Force | Out-Null } $AutopilotOOBEJson | Out-File -FilePath "C:\ProgramData\OSDeploy\OSDeploy.AutopilotOOBE.json" -Encoding ascii -Force #================================================ # [PostOS] SetupComplete CMD Command Line #================================================ Write-Host -ForegroundColor Green "Create C:\Windows\Setup\Scripts\SetupComplete.cmd" $SetupCompleteCMD = @' powershell.exe -Command Set-ExecutionPolicy RemoteSigned -Force powershell.exe -Command "& {IEX (IRM https://oobe.psp.osdcloud.ch)}" '@ $SetupCompleteCMD | Out-File -FilePath 'C:\Windows\Setup\Scripts\SetupComplete.cmd' -Encoding ascii -Force #================================================ # [PostOS] Copying PFX file and script #================================================ Write-Host -ForegroundColor Green "Copying PFX file and script" Copy-Item X:\OSDCloud\Scripts C:\OSDCloud\ -Recurse -Force #======================================================================= # Restart-Computer #======================================================================= Write-Host -ForegroundColor Green "Restarting in 20 seconds!" Start-Sleep -Seconds 20 wpeutil reboot } $attempts = 0 $maxAttempts = 3 $correctPassword = "Setup" while ($attempts -lt $maxAttempts) { # Prompt for password $enteredPassword = Read-Host -Prompt "Enter the password for OSD start" -AsSecureString # Convert the secure string to plain text $Password = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($enteredPassword)) if ($Password -eq $correctPassword) { # Execute your PowerShell script here Write-Host "Password is correct. Executing PowerShell script..." #Start OSDCloudScriptPad # Write-Host -ForegroundColor Green "Start OSDPad" # Start-OSDPad -RepoOwner SupportSekEinsHoefe -RepoName OSD -RepoFolder Profiles -BrandingTitle 'Sek Eins Hoefe - OS Deployment' -OAuth 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 -Hide Script -Color '#FC4242' Write-Host -ForegroundColor Green "Calling OSD function" Start-PSPOSD break } else { $attempts++ Write-Host -ForegroundColor Red "Incorrect password. Attempt $attempts of $maxAttempts. Access denied." } } if ($attempts -eq $maxAttempts) { Write-Host -ForegroundColor Red "Maximum number of attempts reached. Access denied." Read-Host -Prompt "Press Enter to exit" }