Well, it’s really not too complicated. Done it a few times, unfortunately my SSDs with my scripts on are currently residing on the other side of the planet. As soon as I have them with me, I’ll share the code on my blog.
David From: [email protected] [mailto:[email protected]] On Behalf Of Daniel Ratliff Sent: 19 March 2014 08:46 To: '[email protected]'; '[email protected]' Subject: RE: [mssms] Modify Task Sequences with a Script Hmm is it still leveraging wmi? -Daniel Ratliff -----Original Message----- From: Ryan [[email protected] <mailto:[email protected]> ] Sent: Tuesday, March 18, 2014 05:30 PM Eastern Standard Time To: [email protected] <mailto:[email protected]> Subject: Re: [mssms] Modify Task Sequences with a Script Cool, I voted it up also. Thanks! There is some C# code in the SDK I've found to add steps to a task sequence. I may look at taking that information and creating some functions or cmdlets to do this. On Tue, Mar 18, 2014 at 4:03 PM, Trevor Sullivan <[email protected] <mailto:[email protected]> > wrote: Voted. Cheers, Trevor Sullivan From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of Daniel Ratliff Sent: Tuesday, March 18, 2014 4:01 PM To: [email protected] <mailto:[email protected]> Subject: RE: [mssms] Modify Task Sequences with a Script Here you go. Vote away! Also threw a post out on myItForum. Feel free to put any suggestions out there. https://connect.microsoft.com/ConfigurationManagervnext/feedback/details/836341/dcr-ability-to-modify-existing-task-sequence-via-powershell-wmi From: [email protected] <mailto:[email protected]> [mailto:[email protected] <mailto:[email protected]> ] On Behalf Of Daniel Ratliff Sent: Tuesday, March 18, 2014 3:18 PM To: [email protected] <mailto:[email protected]> Subject: RE: [mssms] Modify Task Sequences with a Script Hmm, great idea for a DCR. Ill open it on Connect later today, unless someone beats me to it. From: [email protected] <mailto:[email protected]> [mailto:[email protected]] <mailto:[mailto:[email protected]]> On Behalf Of Trevor Sullivan Sent: Tuesday, March 18, 2014 3:14 PM To: [email protected] <mailto:[email protected]> Subject: RE: [mssms] Modify Task Sequences with a Script +1 I just tried writing up the script below, but it didn’t end up persisting the changes. Cheers, Trevor Sullivan # Specify the task sequence package ID $PackageID = 'LAB00012'; # 1. Get the task sequence package using fully qualified WMI path $TaskSequence = [wmi]"root\sms\site_lab:SMS_TaskSequencePackage.PackageID='LAB00012'"; # 2. Get reference to the SMS_TaskSequence class $TsClass = [wmiclass]"root\sms\site_lab:SMS_TaskSequence" # 3. Load the XML from the task sequence's "Sequence" property into a SMS_TaskSequence instance $TS = $TsClass.LoadFromXml($TaskSequence.Sequence).ReturnValue; # 4. Get a reference to one of the task sequence step types $SetVarClass = [wmiclass]"root\sms\site_lab:SMS_TaskSequence_SetVariableAction" # 5. Instantiate the task sequence action class $NewSetVarAction = $SetVarClass.CreateInstance(); # 6. Set appropriate properties on the Action $NewSetVarAction.Name = '[PowerShell] Set Variable'; $NewSetVarAction.VariableName = 'OSDPreserveDriveLetter'; $NewSetVarAction.VariableValue = 'False'; # 7. Add the Action to the task sequence steps $TS.Steps += $NewSetVarAction; # 8. Commit the modified WMI object back into XML $NewTS = $TsClass.SaveToXml($TS); # 9. Set the XML on the Sequence property of the SMS_TaskSequence $TaskSequence.Sequence = $NewTS.ReturnValue; # 10. Commit the task sequence changes to WMI $TaskSequence.Put(); From: [email protected] <mailto:[email protected]> [mailto:[email protected]] <mailto:[mailto:[email protected]]> On Behalf Of Daniel Ratliff Sent: Tuesday, March 18, 2014 2:02 PM To: [email protected] <mailto:[email protected]> Subject: RE: [mssms] Modify Task Sequences with a Script I have tried this for a good year now. I can export them and document them, but don’t have a way to edit them on the fly without creating new ones with the changes. From: [email protected] <mailto:[email protected]> [mailto:[email protected]] <mailto:[mailto:[email protected]]> On Behalf Of Ryan Sent: Tuesday, March 18, 2014 2:52 PM To: [email protected] <mailto:[email protected]> Subject: [mssms] Modify Task Sequences with a Script Does anyone here know how to modify a task sequence with a script? I'm taking adding task sequence variables, application install steps, driver steps, etc etc... I'd very much like to make tools to make some task sequence creation steps easier and I don't want to have to learn C# to do it. The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information. The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information. The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information. The information transmitted is intended only for the person or entity to which it is addressed and may contain CONFIDENTIAL material. If you receive this material/information in error, please contact the sender and delete or destroy the material/information.

