forked from artisticcheese/artisticcheesecontainer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.ps1
46 lines (43 loc) · 1.64 KB
/
startup.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
$VerbosePreference = "Continue"
$ErrorActionPreference = "Continue"
$ContainerAdmin = $env:ContainerAdmin
$ContainerPassword = $env:ContainerPassword
if ((Get-LocalUser -Name $ContainerAdmin ).Count -eq 1) {
Write-Verbose "Admin container user already exists, updating password to $ContainerPassword"
Set-localuser -Name $ContainerAdmin -Password (ConvertTo-SecureString $ContainerPassword -AsPlainText -Force)
}
else {
Write-Verbose "Admin container does not exist, creating user"
new-LocalUser -Name $ContainerAdmin -Password (ConvertTo-SecureString $ContainerPassword -AsPlainText -Force)
}
if (((Get-LocalGroupMember administrators) -notmatch $ContainerAdmin)) {
Write-Verbose "$containeradmin is not part of local Administrator's group, adding it"
Add-LocalGroupMember -Group Administrators -Member $ContainerAdmin
}
<# Configuration Startup
{
param
(
[pscredential] $cred
)
Import-DscResource -ModuleName 'PSDSCResources'
node localhost{
User LocalAdmin {
UserName = $cred.UserName
Description = "Customized admin for container"
Ensure = "Present"
Password = $cred
}
}
}
$cd = @{
AllNodes = @(
@{
NodeName = 'localhost'
PSDscAllowPlainTextPassword = $true
}
)
}
$cred = [pscredential]::new($ContainerAdmin, (ConvertTo-SecureString $ContainerPassword -AsPlainText -Force))
Startup -cred $cred -ConfigurationData $cd
Start-DscConfiguration -Wait -Verbose -Path .\Startup -Force#>