-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathcimsession.ps1
97 lines (47 loc) · 1.64 KB
/
cimsession.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
create csv file add two neighbour computernames
configuration to create folder on remote machine
configuration has to be using paramter
Start-DscConfiguration -Path C:\demo -CimSession
configuration config3
{
Import-DscResource -ModuleName Psdesiredstateconfiguration
Node tigerpc
{
file createfolder
{
Type = 'Directory'
DestinationPath = "C:\Dinesh"
Force =$true
}
}
}
config3
$cred = Get-Credential
$cimoption = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl
$cim =New-CimSession -Credential (Get-Credential) -ComputerName tigerpc -Port 5986 -SessionOption $cimoption
Start-DscConfiguration -CimSession $cim -Path C:\Demo\config4 -wait -Verbose
tigerpc 192.168.1.24
administrator ntms123#
$csvdetails = import-csv C:\Demo\tiger.csv
configuration config4
{
param($compname)
Import-DscResource -ModuleName Psdesiredstateconfiguration
Node $compname
{
file dineshfolder
{
DestinationPath = "C:\dinesh\chapter1"
type='Directory'
Force = $true
}
}
}
config4
foreach ($com in $csvdetails)
{
config4 -compname $com.compname -outputpath C:\demo\config4
$cimoption = New-CimSessionOption -SkipCACheck -SkipCNCheck -UseSsl
$cim =New-CimSession -Credential $cred -ComputerName $com.compname -Port 5986 -SessionOption $cimoption
Start-DscConfiguration -path C:\demo\config4 -wait -Verbose
}