-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNewRoleDirectory.ps1
56 lines (42 loc) · 1.44 KB
/
NewRoleDirectory.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
Param
(
[Parameter(Mandatory = $true, Position = 0)] # Service Profile name
[String]$RoleName
)
$shareRoot = ".\Roles" # Local share root
$RolePath = Join-Path $shareRoot $RoleName
$RoleDSC = Join-Path $RolePath "DSC"
$DSCTemp = Join-Path $RoleDSC "Temp"
$RoleConfig = Join-Path $RolePath "Config"
If (Test-Path $RolePath) {
Write-Host "Directory $RolePath already exists. Exiting" -ForegroundColor Red
Exit
}
$null = New-Item -Path $RolePath -ItemType Container
$null = New-Item -Path $RoleDSC -ItemType Container
#$null = New-Item -Path $RoleDSC -Name "DSC$($RoleName).ps1" -ItemType File
$null = New-Item -Path $DSCTemp -ItemType Container
$null = New-Item -Path $DSCTemp -Name "DSC_MOF_FILES" -ItemType File
$null = New-Item -Path $RoleConfig -ItemType Container
$null = New-Item -Path $RoleConfig -Name "DSC_CONFIG_FILE_JSON" -ItemType File
$ConfPath = '$ConfPath'
$AllNodes = '$AllNodes'
@"
param (
$($ConfPath)
)
configuration $($RoleName)
{
Import-DscResource -ModuleName PSDesiredStateConfiguration
Import-DscResource -ModuleName ComputerManagementDsc
Node $($AllNodes).NodeName
{
}
}
$($RoleName) -outputPath "$($RoleDSC)\temp\" -ConfigurationData $($ConfPath)
"@ | Out-File "$($RoleDSC)\DSC$($RoleName).ps1" -Encoding utf8
Write-Host "Directories created:"
Write-Host " $RolePath"
Write-Host " $RoleDSC"
Write-Host " $DSCTemp"
Write-Host " $RoleConfig `n"