Jump to content


  • 0
jHetzer

OSD Run Command Line: One-Liners

Question

OSD Run Command Line: One Liners

Please find attached a set of usefull SCCM OSD Task Sequence "Run Command Line" One-Liners

Show Task Sequence Name in SCCM Status Messages:

cmd.exe /C "echo %_SMSTSPackageName%"

Format Disk 0 for Staging (Remove Bitlocker before downloading first Package)

cmd.exe /c "(echo select disk 0&& echo.clean&& echo.list disk&& echo.list volume) > .\diskpart.txt && diskpart.exe /s .\diskpart.txt"

Adjust OSDDiskIndex (Max two disks)
(Useful if a device has two disk and either one can/should be the C drive. Work in combination with the step "Format and Partition Disk" and overwrites the "Disk Number" value)

cmd.exe /V /C "(set /a osdID=1-%OSDDiskIndex% > null&& tsenv.exe "OSDDiskIndex=!osdID!")"

Set Drive Offline/Online by variable
(see: Bitlocker Pre-Provision multi Disk)

cmd.exe /c "(echo select disk %OSDDiskIndex%&& echo.offline disk&& echo.list disk) > .\diskpart.txt && diskpart.exe /s .\diskpart.txt"
cmd.exe /c "(echo select disk %OSDDiskIndex%&& echo.online disk&& echo.list disk) > .\diskpart.txt && diskpart.exe /s .\diskpart.txt"

Fix Drive Letter of mounted devices
(Best used in combination with conditions)

cmd.exe /V /C "FOR /F %V IN ('mountvol.exe D: /L') DO (mountvol.exe D: /D & mountvol.exe F: %V)"

image.png.3abbef73166035824a649b6922c5d14f.png
(Checks if devices has one disk and device with drive letter D is an USB Drive --> Map USB from D to F Drive Letter)

image.png.589403421be5d34f59313669c5ccb5aa.png
(Checks if devices has one disk and device with drive letter D is an CDRomDrive --> Map CDRom from D to E Drive Letter)

Forcefully halt the task sequence
(The file does not exist and therefor generates an error, best/only to use with conditions)
Enables Task Sequence Powershell special return codes

StopTaskSequenceWithError.exe

image.png.ea48f6780baa72a890cb2bc1f74794d4.png

The step before is a "Run PowerShell Script" step and may return "SomeRandomPs1ReturnCode". But the step does not support defining return codes. To overcome this issue change the powershell script or set "Continue on Error" and create this step afterwards.

 

If you like this collection and have some other useful commands by your own please share them in a "reply to this Topic"

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.