diff --git a/CopyFilesToVM.ps1 b/CopyFilesToVM.ps1 index 7f6e231..8563b3e 100644 --- a/CopyFilesToVM.ps1 +++ b/CopyFilesToVM.ps1 @@ -2,15 +2,35 @@ Function Setup-ParsecInstall { param( -[string]$DriveLetter +[string]$DriveLetter, +[string]$Team_ID, +[string]$Key ) - + $new = @() + + $content = get-content "$PSScriptRoot" + "\user\psscripts.ini" + + foreach ($line in $content) { + if ($line -like "0Parameters="){ + $line = "0Parameters=-team_id=$Team_ID -team_key=$Key" + $new += $line + } + Else { + $new += $line + } + } + Set-Content -Value $new -Path "$PSScriptRoot" + "\user\psscripts.ini" if((Test-Path -Path $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logon) -eq $true) {} Else {New-Item -Path $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logon -ItemType directory | Out-Null} if((Test-Path -Path $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logoff) -eq $true) {} Else {New-Item -Path $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logoff -ItemType directory | Out-Null} + if((Test-Path -Path $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts\Startup) -eq $true) {} Else {New-Item -Path $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts\Startup -ItemType directory | Out-Null} + if((Test-Path -Path $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts\Shutdown) -eq $true) {} Else {New-Item -Path $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts\Shutdown -ItemType directory | Out-Null} if((Test-Path -Path $DriveLetter\ProgramData\Easy-GPU-P) -eq $true) {} Else {New-Item -Path $DriveLetter\ProgramData\Easy-GPU-P -ItemType directory | Out-Null} + Copy-Item -Path $psscriptroot\cert.bat -Destination $DriveLetter\ProgramData\Easy-GPU-P Copy-Item -Path $psscriptroot\gpt.ini -Destination $DriveLetter\Windows\system32\GroupPolicy - Copy-Item -Path $psscriptroot\psscripts.ini -Destination $DriveLetter\Windows\system32\GroupPolicy\User\Scripts - Copy-Item -Path $psscriptroot\Install.ps1 -Destination $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logon + Copy-Item -Path $psscriptroot\User\psscripts.ini -Destination $DriveLetter\Windows\system32\GroupPolicy\User\Scripts + Copy-Item -Path $psscriptroot\User\Install.ps1 -Destination $DriveLetter\Windows\system32\GroupPolicy\User\Scripts\Logon + Copy-Item -Path $psscriptroot\Machine\psscripts.ini -Destination $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts + Copy-Item -Path $psscriptroot\Machine\Install.ps1 -Destination $DriveLetter\Windows\system32\GroupPolicy\Machine\Scripts\Startup Copy-Item -Path $psscriptroot\parsecpublic.cer -Destination $DriveLetter\ProgramData\Easy-GPU-P } @@ -255,6 +275,18 @@ function Convert-WindowsImage { [ValidateNotNullOrEmpty()] [string]$GPUName, + [Parameter(ParameterSetName="SRC")] + [Alias("TeamID")] + [string] + [ValidateNotNullOrEmpty()] + [string]$Team_ID, + + [Parameter(ParameterSetName="SRC")] + [Alias("Team_Key")] + [string] + [ValidateNotNullOrEmpty()] + [string]$Key, + [Parameter(ParameterSetName="SRC")] [switch] $CacheSource = $false, @@ -2369,7 +2401,7 @@ You can use the fields below to configure the VHD or VHDX that you want to creat } Write-W2VInfo "Setting up Parsec to install at boot" - Setup-ParsecInstall -DriveLetter $WindowsDrive + Setup-ParsecInstall -DriveLetter $WindowsDrive -Team_ID $team_id -Key $key if ($DiskLayout -eq "UEFI") { @@ -4187,10 +4219,12 @@ param( [int]$CPUCores, [string]$GPUName, [float]$GPUResourceAllocationPercentage, -[string]$SourcePath +[string]$SourcePath, +[string]$Team_ID, +[string]$Key ) - #New-vhd -SizeBytes $HDDSize -Path "C:\Users\Public\Documents\Hyper-V\Virtual hard disks\$VMName.vhdx" -Dynamic - Convert-WindowsImage -SourcePath $SourcePath -Edition $Edition -VHDFormat $Vhdformat -VHDPath $VhdPath -DiskLayout $DiskLayout -UnattendPath $UnattendPath -GPUName $GPUName | Out-Null + + Convert-WindowsImage -SourcePath $SourcePath -Edition $Edition -VHDFormat $Vhdformat -VHDPath $VhdPath -DiskLayout $DiskLayout -UnattendPath $UnattendPath -GPUName $GPUName -Team_ID $Team_ID -Key $Key| Out-Null New-VM -Name $VMName -MemoryStartupBytes $MemoryAmount -VHDPath $VhdPath -Generation 2 -SwitchName "Default Switch" | Out-Null Set-VM -Name $VMName -ProcessorCount $CPUCores -CheckpointType Disabled -LowMemoryMappedIoSpace 3GB -HighMemoryMappedIoSpace 32GB -GuestControlledCacheTypes $true -AutomaticStopAction ShutDown Set-VMMemory -VMName $VMName -DynamicMemoryEnabled $false @@ -4212,6 +4246,8 @@ $params = @{ UnattendPath = "$PSScriptRoot"+"\autounattend.xml" GPUName = "NVIDIA GeForce GTX 1050 Ti with Max-Q Design" GPUResourceAllocationPercentage = 25 + Team_ID = "1mhDZ8RNbpGwFYwGYrMu9ewwcby" + Key = "ae31d6e201227b7caa977a0a9bce83652e67f29662d284c5e5c20db61e6d16d2" } @@ -4219,3 +4255,4 @@ New-GPUEnabledVM @params +Start-VM -Name GPU-P \ No newline at end of file diff --git a/Install.ps1 b/Install.ps1 deleted file mode 100644 index 077167d..0000000 --- a/Install.ps1 +++ /dev/null @@ -1,60 +0,0 @@ -while(!(Test-NetConnection Google.com).PingSucceeded){ - Start-Sleep -Seconds 1 - } - -if (Test-Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Parsec) - {} - else { - (New-Object System.Net.WebClient).DownloadFile("https://builds.parsecgaming.com/package/parsec-windows.exe", "C:\Users\$env:USERNAME\Downloads\parsec-windows.exe") - (New-Object System.Net.WebClient).DownloadFile("https://builds.parsec.app/vdd/parsec-vdd-0.37.0.0.exe", "C:\Users\$env:USERNAME\Downloads\parsec-vdd.exe") - Start-Process "C:\Users\$env:USERNAME\Downloads\parsec-windows.exe" -ArgumentList "/silent", "/shared" -wait - $Success = $false - [int]$Retries = 0 - do { - try { - Import-Certificate -CertStoreLocation Cert:\LocalMachine\TrustedPublisher -FilePath "C:\ProgramData\Easy-GPU-P\parsecpublic.cer" - $Success = $true - } - catch { - if ($Retries -gt 9){ - $Success = $true - } - else { - Start-Sleep -Seconds 5 - $Retries++ - } - } - } - While ($Success -eq $false) - Start-Process "C:\Users\$env:USERNAME\Downloads\parsec-vdd.exe" -ArgumentList "/silent" -wait - $configfile = Get-Content C:\ProgramData\Parsec\config.txt - $configfile += "host_virtual_monitors = 1" - $configfile += "host_privacy_mode = 1" - $configfile | Out-File C:\ProgramData\Parsec\config.txt -Encoding ascii - Stop-Process Parsec -Force - } - - $Stoploop = $false -[int]$Retrycount = "0" - - - -do { -try { - -Write-Host "Job completed" -$Stoploop = $true -} -catch { -if ($Retrycount -gt 3){ -Write-Host "Could not send Information after 3 retrys." -$Stoploop = $true -} -else { -Write-Host "Could not send Information retrying in 30 seconds..." -Start-Sleep -Seconds 30 -$Retrycount = $Retrycount + 1 -} -} -} -While ($Stoploop -eq $false) \ No newline at end of file diff --git a/Machine/Install.ps1 b/Machine/Install.ps1 new file mode 100644 index 0000000..946fe6d --- /dev/null +++ b/Machine/Install.ps1 @@ -0,0 +1,33 @@ +<# +if (!(Test-Path C:\ProgramData\Easy-GPU-P\second.txt)) { + exit + } +else { + if( !((Get-ChildItem -Path Cert:\CurrentUser\TrustedPublisher).DnsNameList.Unicode -like "Parsec Cloud, Inc.")) { + $Success = $false + [int]$Retries = 0 + do { + try { + Import-Certificate -CertStoreLocation Cert:\CurrentUser\TrustedPublisher -FilePath C:\ProgramData\Easy-GPU-P\parsecpublic.cer + $Success = $true + } + catch { + if ($Retries -gt 60){ + $Success = $true + } + else { + Start-Sleep -Seconds 1 + $Error[0] |Out-File C:\ProgramData\Easy-GPU-P\log.txt + $env:USERNAME | Out-File C:\ProgramData\Easy-GPU-P\username.txt + $Retries++ + + } + } + } + While ($Success -eq $false) + + } + Else { + } + } +#> \ No newline at end of file diff --git a/psscripts.ini b/Machine/psscripts.ini similarity index 50% rename from psscripts.ini rename to Machine/psscripts.ini index 52d1a45..7b4cd05 100644 --- a/psscripts.ini +++ b/Machine/psscripts.ini @@ -1,4 +1,4 @@ -[Logon] +[Startup] 0CmdLine=Install.ps1 0Parameters= \ No newline at end of file diff --git a/User/Install.ps1 b/User/Install.ps1 new file mode 100644 index 0000000..c9ef8c7 --- /dev/null +++ b/User/Install.ps1 @@ -0,0 +1,53 @@ +param( +$team_id, +$key +) + +while(!(Test-NetConnection Google.com).PingSucceeded){ + Start-Sleep -Seconds 1 + } + +if (Test-Path HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Parsec) + {} + else { + (New-Object System.Net.WebClient).DownloadFile("https://builds.parsecgaming.com/package/parsec-windows.exe", "C:\Users\$env:USERNAME\Downloads\parsec-windows.exe") + (New-Object System.Net.WebClient).DownloadFile("https://builds.parsec.app/vdd/parsec-vdd-0.37.0.0.exe", "C:\Users\$env:USERNAME\Downloads\parsec-vdd.exe") + $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) + $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) | Out-File C:\ProgramData\Easy-GPU-P\admim.txt + Start-Process "C:\Users\$env:USERNAME\Downloads\parsec-windows.exe" -ArgumentList "/silent", "/shared","/team_id=$team_id","/team_computer_key=$key" -wait + $configfile = Get-Content C:\ProgramData\Parsec\config.txt + $configfile += "host_virtual_monitors = 1" + $configfile += "host_privacy_mode = 1" + $configfile | Out-File C:\ProgramData\Parsec\config.txt -Encoding ascii + } + +<# + if (!((Get-ChildItem -Path Cert:\CurrentUser\TrustedPublisher).DnsNameList.Unicode -like "Parsec Cloud, Inc.")) { + cmd /c C:\ProgramFiles\Easy-GPU-P\cert.bat + } + + Invoke-Item Cert:\CurrentUser\TrustedPublisher + start-sleep -s 30 + + +if (!((Get-ChildItem -Path Cert:\CurrentUser\TrustedPublisher).DnsNameList.Unicode -like "Parsec Cloud, Inc.")) { + Import-Certificate -CertStoreLocation Cert:\CurrentUser\TrustedPublisher -FilePath C:\ProgramData\Easy-GPU-P\parsecpublic.cer +if (!(Test-Path C:\ProgramData\Easy-GPU-P\second.txt)) { + New-Item -ItemType File -Path C:\ProgramData\Easy-GPU-P\second.txt + Restart-Computer + } +} +#> + + +#if(((Get-ChildItem -Path Cert:\CurrentUser\TrustedPublisher).DnsNameList.Unicode -like "Parsec Cloud, Inc.")) { + if (!(Get-WmiObject Win32_VideoController | Where-Object name -like "Parsec Virtual Display Adapter")) { + cmd /c C:\ProgramFiles\Easy-GPU-P\cert.bat + Start-Process "C:\Users\$env:USERNAME\Downloads\parsec-vdd.exe" -ArgumentList "/silent" + } + +<#} +Else { +Restart-Computer +} +#> diff --git a/User/psscripts.ini b/User/psscripts.ini new file mode 100644 index 0000000..adbdeff --- /dev/null +++ b/User/psscripts.ini @@ -0,0 +1,4 @@ + +[Logon] +0CmdLine=Install.ps1 +0Parameters=-team_id 1mhDZ8RNbpGwFYwGYrMu9ewwcby -key ae31d6e201227b7caa977a0a9bce83652e67f29662d284c5e5c20db61e6d16d2 \ No newline at end of file diff --git a/autounattend.xml b/autounattend.xml index 13ac55b..5b9babc 100644 --- a/autounattend.xml +++ b/autounattend.xml @@ -131,7 +131,7 @@ Notes: Enter your comments here... 0 --PC +GPU-P W269N-WFGWX-YVC9B-4J6C9-T83GX @@ -182,13 +182,13 @@ Notes: Enter your comments here... Allow Scripts 2 -reg add HKLM\Software\Policies\Microsoft\Windows\Powershell /v Unrestricted /t REG_SZ ExecutionPolicy +reg add HKLM\Software\Policies\Microsoft\Windows\Powershell /v ExecutionPolicy /t REG_SZ /d Unrestricted false Allow Scripts 3 -reg add HKLM\Software\Policies\Microsoft\Windows\Powershell /v 1 /t REG_DWORD EnableScripts +reg add HKLM\Software\Policies\Microsoft\Windows\Powershell /v EnableScripts /t REG_DWORD /d 1 false diff --git a/cert.bat b/cert.bat new file mode 100644 index 0000000..08b913c --- /dev/null +++ b/cert.bat @@ -0,0 +1 @@ +certutil -addstore -f "TrustedPublisher" C:\ProgramData\Easy-GPU-P\parsecpublic.cer diff --git a/gpt.ini b/gpt.ini index 01c6ad7..895c9bf 100644 --- a/gpt.ini +++ b/gpt.ini @@ -1,3 +1,4 @@ [General] gPCUserExtensionNames=[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B66650-4972-11D1-A7CA-0000F87571E3}] -Version=131072 \ No newline at end of file +Version=131074 +gPCMachineExtensionNames=[{42B5FAAE-6536-11D2-AE5A-0000F87571E3}{40B6664F-4972-11D1-A7CA-0000F87571E3}] \ No newline at end of file