zh-TW 0404:00000404 zh-TW zh-TW zh-TW $$VT_WINDOWS_DISK_1ST_NONVTOY$$ true 1EFI500 2MSR128 3Primarytrue 11 FAT32 23 NTFSC $$VT_WINDOWS_DISK_1ST_NONVTOY$$3 false W269N-WFGWX-YVC9B-4J6C9-T83GX OnError true IT Department YourCompany * Taipei Standard Time IT Department YourCompany 0404:00000404 zh-TW zh-TW zh-TW true true true true Work 3 true true Admin Administrator Administrators P@ssw0rd! true</PlainText> </Password> </LocalAccount> </LocalAccounts> </UserAccounts> <AutoLogon> <Username>Admin</Username> <Enabled>true</Enabled> <LogonCount>1</LogonCount> <Password> <Value>P@ssw0rd!</Value> <PlainText>true</PlainText> </Password> </AutoLogon> <!-- 首次登入執行的自訂腳本 --> <FirstLogonCommands> <SynchronousCommand wcm:action="add"> <Order>1</Order> <CommandLine>powershell.exe -ExecutionPolicy Bypass -File C:\Scripts\Setup.ps1</CommandLine> <Description>執行部署後設定腳本</Description> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>2</Order> <CommandLine>cmd.exe /c net accounts /maxpwage:unlimited</CommandLine> <Description>密碼永不過期</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>3</Order> <CommandLine>powershell.exe -NoProfile -Command "Rename-Computer -NewName ('PC-' + (Get-Random -Minimum 10000 -Maximum 100000)) -Force"</CommandLine> <Description>主機名改成 PC-XXXXX(重開後生效)</Description> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>4</Order> <CommandLine>cmd.exe /c "net user user 1234 /add &amp; net user user /logonpasswordchg:yes"</CommandLine> <Description>建立本機帳號 user(密碼 1234,首次登入強制改密)</Description> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>5</Order> <CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$log='C:\Windows\Temp\firstlogon-sshd.log'; $i=0; while ($i -lt 30 -and -not (Test-Connection 8.8.8.8 -Count 1 -Quiet -EA 0)) { Start-Sleep 2; $i++ }; ('NetWait=' + ($i*2) + 's') | Out-File $log -Append; try { Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 -EA Stop | Out-Null; Set-Service sshd -StartupType Automatic -EA Stop; Start-Service sshd -EA Stop; ('OK ' + (Get-Date -Format o)) | Out-File $log -Append } catch { ('ERR ' + $_.Exception.Message) | Out-File $log -Append }"</CommandLine> <Description>等網路→安裝並啟用 OpenSSH Server(log: firstlogon-sshd.log)</Description> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>6</Order> <CommandLine>powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "$log='C:\Windows\Temp\firstlogon-telegram.log'; [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; $ProgressPreference='SilentlyContinue'; $p=Join-Path $env:TEMP 'tsetup.exe'; $i=0; while ($i -lt 30 -and -not (Test-Connection 8.8.8.8 -Count 1 -Quiet -EA 0)) { Start-Sleep 2; $i++ }; ('NetWait=' + ($i*2) + 's') | Out-File $log -Append; try { ('Start ' + (Get-Date -Format o)) | Out-File $log -Append; Invoke-WebRequest -UseBasicParsing -Uri 'https://telegram.org/dl/desktop/win64' -OutFile $p; ('Downloaded ' + (Get-Item $p).Length + 'B') | Out-File $log -Append; $proc=Start-Process -FilePath $p -ArgumentList '/VERYSILENT','/SUPPRESSMSGBOXES','/NORESTART' -Wait -PassThru; ('Exit ' + $proc.ExitCode) | Out-File $log -Append } catch { ('ERR ' + $_.Exception.Message) | Out-File $log -Append }"</CommandLine> <Description>下載並靜默安裝 Telegram Desktop(log: firstlogon-telegram.log)</Description> <RequiresUserInput>false</RequiresUserInput> </SynchronousCommand> <SynchronousCommand wcm:action="add"> <Order>7</Order> <CommandLine>shutdown /r /t 5</CommandLine> <Description>完成後重開機</Description> </SynchronousCommand> </FirstLogonCommands> </component> </settings> </unattend>