Browse Source

fix: 调整userdata顺序

iaun 7 months ago
parent
commit
1baac134a3
1 changed files with 3 additions and 3 deletions
  1. 3 3
      server/src/services/userdata.ts

+ 3 - 3
server/src/services/userdata.ts

@@ -44,9 +44,6 @@ export function generateWindowsPassword(length = 16): string {
 export function generateUserData(machineGuid: string, adminPassword: string): string {
   const script = [
     '<powershell>',
-    `Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Cryptography" -Name "MachineGuid" -Value "${machineGuid}"`,
-    `net user Administrator '${adminPassword}'`,
-    '',
     '# Configure GlobalProtect portal registry settings',
     'New-Item -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\PanSetup" -Force | Out-Null',
     'Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Palo Alto Networks\\GlobalProtect\\PanSetup" -Name "Portal" -Value "yidingyingecv.lab.gpcloudservice.com"',
@@ -58,6 +55,9 @@ export function generateUserData(machineGuid: string, adminPassword: string): st
     'if (-not (Test-Path "C:\\Program Files\\Palo Alto Networks\\GlobalProtect\\PanGPS.exe")) {',
     '    Start-Process msiexec.exe -ArgumentList \'/i "C:\\Users\\Administrator\\Downloads\\GlobalProtect64.msi" DEFAULTBROWSER=YES /quiet /norestart\' -Wait',
     '}',
+    '',
+    `Set-ItemProperty -Path "HKLM:\\SOFTWARE\\Microsoft\\Cryptography" -Name "MachineGuid" -Value "${machineGuid}"`,
+    `net user Administrator '${adminPassword}'`,
     '</powershell>',
     '<persist>true</persist>',
   ].join('\n');