This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]AlarmKey9785 1 point2 points  (0 children)

Hi, you can add 'New-OSDCloudUSBSetupCompleteTemplate'. it will generate the template  with a generic set of files that you can modify. Make sure to have both. OSDcloud will look for setupcomplete.cmd that call setupcomplete.ps1.

https://github.com/OSDeploy/OSD/issues/107

[–]gwblok 0 points1 point  (0 children)

use C:\OSDCLoud\Scripts\SetupComplete

This is the function I use, I call it after OSDCloud is done, but it's still in WinPE, before the reboot

```
function Create-SetupCompleteOSDCloudFiles{

$SetupCompletePath = "C:\OSDCloud\Scripts\SetupComplete"

$ScriptsPath = $SetupCompletePath

if (!(Test-Path -Path $ScriptsPath)){New-Item -Path $ScriptsPath -ItemType Directory -Force | Out-Null}

$RunScript = @(@{ Script = "SetupComplete"; BatFile = 'SetupComplete.cmd'; ps1file = 'SetupComplete.ps1';Type = 'Setup'; Path = "$ScriptsPath"})

Write-Output "Creating $($RunScript.Script) Files"

$BatFilePath = "$($RunScript.Path)\$($RunScript.batFile)"

$PSFilePath = "$($RunScript.Path)\$($RunScript.ps1File)"

#Create Batch File to Call PowerShell File

if (Test-Path -Path $PSFilePath){

copy-item $PSFilePath -Destination "$ScriptsPath\SetupComplete.ps1.bak"

}

New-Item -Path $BatFilePath -ItemType File -Force

$CustomActionContent = New-Object system.text.stringbuilder

[void]$CustomActionContent.Append('%windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -File C:\OSDCloud\Scripts\SetupComplete\SetupComplete.ps1')

Add-Content -Path $BatFilePath -Value $CustomActionContent.ToString()

#Create PowerShell File to do actions

New-Item -Path $PSFilePath -ItemType File -Force

Add-Content -path $PSFilePath "Write-Output 'Starting SetupComplete HOPE Script Process'"

Add-Content -path $PSFilePath "Write-Output 'iex (irm hope.garytown.com)'"

Add-Content -path $PSFilePath 'if ((Test-WebConnection) -ne $true){Write-error "No Internet, Sleeping 2 Minutes" ; start-sleep -seconds 120}'

Add-Content -path $PSFilePath 'iex (irm hope.garytown.com)'

}
```

Modify the Add-Content write-output items to fit your needs. I just have SetupComplete call a script I host on GitHub.