As well as double-clicking the .exe and walking through its interactive menus, OSManagerCLI can run a ‘hands-free’ reimage as part of one of your automation scripts, straight from the command line:
.\ OSManagerCLI.exe - PreIngestedOSFileHandle ' gx3p_25Q3_f0885a6e ' - MachineToReimageHandle ' gx3p-42123 '
You can tell if a reimage was successful or not by checking the exit code (0 means success).
.\ OSManagerCLI.exe - PreIngestedOSFileHandle ' gx3p_25Q3_f0885a6e ' - MachineToReimageHandle ' gx3p-42123 '
$reimageSuccessExitCode = $LASTEXITCODE
if ( $reimageSuccessExitCode -eq 0 ) {
Write-Host " Reimage Was Successful "
$exitCodesMeaning = & .\ OSManagerCLI.exe - DescribeExitCode $reimageSuccessExitCode
Write-Host " Reimage Failed with Exit Code $reimageSuccessExitCode , which means: $exitCodesMeaning "
OSManagerCLI requires Administrator rights, so it relaunches itself in a new elevated window if you are not already running in a Terminal ‘(As Administrator)’. If you are in a non-elevated session, to capture its exit code from a script, start it elevated and wait for it to finish:
$run = Start-Process .\ OSManagerCLI.exe `
- ArgumentList ' -PreIngestedOSFileHandle ' , ' gx3p_25Q3_f0885a6e ' , ' -MachineToReimageHandle ' , ' MYSERVER ' `
- Verb RunAs - Wait - PassThru
$reimageSuccessExitCode = $run .ExitCode # 0 = success; see the tables below
Write-Host " Exit Code Was: $reimageSuccessExitCode "
Parameter Description -IngestOSFilePath <path>Ingest the OS image at <path> (an .iso or .os file) into your OS Library. -PreIngestedOSFileHandle <handle>Use an OS you’ve already ingested, identified by its handle (the name shown in the OS list). Requires -MachineToReimageHandle. -MachineToReimageHandle <hostname>The server (Actor) to reimage. Requires an OS source: one of the two parameters above must be set. -HelpPrint usage for every parameter, then exit. -VersionPrint just the version number of the current .exe (e.g. 1.12), for easy scripting, then exit. -DescribeExitCode <n>Print the name and meaning of a single exit code, then exit. -ListExitCodesPrint the full exit-code table, then exit.
A few rules the tool enforces:
-IngestOSFilePath and -PreIngestedOSFileHandle can’t be used together. They’re two ways of choosing the same thing.
-MachineToReimageHandle needs an OS source as well.
-PreIngestedOSFileHandle needs -MachineToReimageHandle.
OSManagerCLI.exe - IngestOSFilePath " D:\OSImages\gx3p_25Q3_f0885a6e.iso "
# Reimage a server using an OS you've already ingested
OSManagerCLI.exe - PreIngestedOSFileHandle gx3p_25Q3_f0885a6e - MachineToReimageHandle MYSERVER
# Ingest an OS and reimage a server in one go
OSManagerCLI.exe - IngestOSFilePath " D:\OSImages\gx3p_25Q3_f0885a6e.iso " - MachineToReimageHandle MYSERVER
OSManagerCLI returns a meaningful exit code so that scripts (and you) can tell exactly how a run ended. 0 means success; anything else indicates why it stopped.
Code Name Meaning 0 SuccessCompleted successfully, or you quit normally.
Code Name Meaning 100 ParamMutuallyExclusiveSources-IngestOSFilePath and -PreIngestedOSFileHandle were both supplied (use only one).101 ParamMachineHandleNeedsOsSource-MachineToReimageHandle was supplied without an OS source.102 ParamPreIngestedHandleNeedsMachine-PreIngestedOSFileHandle was supplied without -MachineToReimageHandle.
Code Name Meaning 200 ConfigInvalidJsonThe config file contains invalid JSON. 201 NoDeploymentShareFolderSelectedNo OS Library (deployment share) folder was selected. 202 DeploymentShareSetupFailedAsAdminDeployment share setup failed while running as Administrator. 203 DeploymentShareSetupNeedsAdminDeployment share setup is incomplete and needs Administrator rights. 204 SevenZipMissingUserDeclined7-Zip wasn’t found and you chose not to continue without it. 205 D3ServiceMissingUserDeclinedd3Service wasn’t detected and you chose not to continue without it. 206 PasswordProtectedSharingGuestMissingPassword Protected Sharing couldn’t be disabled (the built-in Guest account wasn’t found). 207 PasswordProtectedSharingUserDeclinedYou declined to disable Password Protected Sharing (which requires enabling the Guest account). 208 GuestNetworkAccessPolicyUndeterminedCouldn’t determine the Windows Guest network-access policy. 209 GuestNetworkAccessUserDeclinedYou declined the Windows policy change that lets servers reach the deployment share on your laptop. 210 LocalD3ServiceVersionTooLowThe d3/Designer version installed on this machine is below the minimum required. 211 D3InstalledButServiceNotRunningd3/Designer is installed on this machine but the d3Service process isn’t running, so the local API is unreachable.
Code Name Meaning 300 HeadlessOsHandleNotFoundThe pre-ingested OS handle wasn’t found in your OS Library. 301 HeadlessOsLibraryEmptyYour OS Library is empty (nothing has been ingested yet).
Code Name Meaning 400 HeadlessIngestSevenZipPathNotSetThe 7-Zip path isn’t set in the config. 401 HeadlessIngestSevenZipPathInvalidThe configured 7-Zip path doesn’t exist. 402 HeadlessIngestArchiveUnreadable7-Zip couldn’t read the archive (invalid or corrupt file). 403 HeadlessIngestNotEnoughDiskSpaceNot enough disk space to extract the archive. 404 HeadlessIngestCreateDirFailedCouldn’t create the OS Library destination folder. 405 HeadlessIngestExtractionFailed7-Zip returned an error while extracting the archive. 406 HeadlessIngestNotExactlyTwoWimsThe archive didn’t contain exactly two .wim files. 407 HeadlessIngestNotExactlyOneBootWimThe archive didn’t contain exactly one boot .wim file. 408 HeadlessIngestOsDirNotExactlyOneWimThe /OS folder didn’t contain exactly one .wim file. 409 HeadlessIngestSourcesDirNotExactlyOneBootWimThe /sources folder didn’t contain exactly one boot .wim file. 410 HeadlessIngestOsWimMoveFailedCouldn’t move the OS .wim into the OS Library. 411 HeadlessIngestBootWimMoveFailedCouldn’t move the boot .wim into the OS Library. 412 HeadlessIngestFileNotFoundThe file given to -IngestOSFilePath doesn’t exist.
Code Name Meaning 500 HeadlessRedisguiseNoServerSelectedNo server was selected. 501 HeadlessRedisguiseNoOsSelectedNo OS was selected. 502 HeadlessRedisguiseEndpointNotVerifiedCouldn’t resolve and identity-verify the server’s d3Service API endpoint. DNS-SD discovery and the last-known address were both tried; the intended machine couldn’t be confirmed on a reachable IP and port. 505 HeadlessRedisguiseNoOsWimNo OS .wim file was found in the selected OS. 506 HeadlessRedisguiseNoBootWimNo boot .wim file was found in the selected OS. 507 HeadlessRedisguiseReimageRequestFailedThe reimage request failed. 509 HeadlessRedisguiseDesignerVersionTooLowThe server’s installed Designer version is below the minimum required, and headless mode can’t prompt to override. 510 HeadlessRedisguiseActorHasRunningProjectThe server has a project open in Designer, and headless mode can’t prompt to override. 511 HeadlessRedisguiseMultipleBootWimsThe OS profile contains more than one boot .wim, and headless mode can’t prompt to pick which one to use.
Code Name Meaning 600 HeadlessUsbNoOsSelectedNo OS was selected for Redisguise USB creation.