-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathcreate_New_TS_with_Group.ps1
32 lines (24 loc) · 1.09 KB
/
create_New_TS_with_Group.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
$Computer = "."
$Class = "SMS_TaskSequencePackage"
$Method = "GetSequence"
$SourceSequence = $Null
$MC = [WmiClass]"\\$Computer\ROOT\SMS\site_PR1:$Class"
$InParams = $mc.psbase.GetMethodParameters($Method)
$TaskSequence = Get-WmiObject -Class SMS_TaskSequencePackage -Namespace root\sms\site_PR1 -Filter "Name = 'Deploy_Win8'"
$InParams.TaskSequencePackage = $TaskSequence
$SourceSequence = $mc.PSBase.InvokeMethod($Method, $inParams, $Null)
# create a blank Sequence
$Sequence = ([WmiClass]"ROOT\SMS\site_PR1:SMS_TaskSequencePackage").ImportSequence('<sequence version="3.00"/>').TaskSequence
$Steps = @()
foreach ($Step in $SourceSequence.TaskSequence.Steps)
{
$Steps += $Step
}
$Sequence.Steps += $Steps
# create the new Task Sequence Package object
$EmptySequence = ([WmiClass]"ROOT\SMS\site_PR1:SMS_TaskSequencePackage").CreateInstance()
$EmptySequence.Name = "NewTS"
$EmptySequence.Description = "New Task Sequence"
$EmptySequence.Category = "OSD"
# commit the new Task Sequence
([WmiClass]"ROOT\SMS\site_PR1:SMS_TaskSequencePackage").SetSequence($EmptySequence,$Sequence)