Last active
May 19, 2016 17:31
-
-
Save guitarrapc/51e721e0c5c42c5bda2c39c0d69a07f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sample configuration | |
configuration Hoge | |
{ | |
Node localhost | |
{ | |
File Hoge | |
{ | |
Ensure = $Node.Ensure | |
DestinationPath = $Node.DestinationPath | |
Type = 'Directory' | |
} | |
User Hoge | |
{ | |
UserName = "Hoge" | |
Password = $Node.Credential | |
Ensure = 'Present' | |
Disabled = $false | |
} | |
} | |
} | |
$cred = (Get-Credential) | |
# create configurationData | |
$configurationData = New-Object 'System.Collections.Generic.Dictionary[string, hashtable[]]' | |
$a = New-Object System.Collections.Hashtable | |
$a.Add("Credential",$cred) | |
$a.Add("NodeName", "*") | |
$a.Add("PSDSCAllowPlainTextPassword", $true) | |
$a.Add("Ensure", "Present") | |
$a.Add("DestinationPath","c:\fuga") | |
$b = New-Object System.Collections.Hashtable | |
$b.Add("NodeName","localhost") | |
$configurationData["AllNodes"] = @($a, $b) | |
Hoge -ConfigurationData $configurationData | |
Start-DscConfiguration -Wait -Force -Verbose Hoge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HashtableComparer : System.Collections.IEqualityComparer | |
{ | |
[bool] Equals([object]$obj, [object]$obj2) | |
{ | |
return $obj -eq $obj2; | |
} | |
[int] GetHashCode([object]$obj) | |
{ | |
return $obj.ToString().ToLower().GetHashCode(); | |
} | |
} | |
$comparer = New-Object HashtableComparer; | |
# sample configuration | |
configuration Hoge | |
{ | |
Node localhost | |
{ | |
File Hoge | |
{ | |
Ensure = $Node.Ensure | |
DestinationPath = $Node.DestinationPath | |
Type = 'Directory' | |
} | |
User Hoge | |
{ | |
UserName = "Hoge" | |
Password = $Node.Credential | |
Ensure = 'Present' | |
Disabled = $false | |
} | |
} | |
} | |
$cred = (Get-Credential) | |
# create configurationData | |
$configurationData = New-Object 'System.Collections.Generic.Dictionary[string, hashtable[]]' | |
$a = New-Object System.Collections.Hashtable ($comparer) | |
$a.Add("Credential",$cred) | |
$a.Add("NodeName", "*") | |
$a.Add("PSDSCAllowPlainTextPassword", $true) | |
$a.Add("Ensure", "Present") | |
$a.Add("DestinationPath","c:\fuga") | |
$b = New-Object System.Collections.Hashtable ($comparer) | |
$b.Add("NodeName","localhost") | |
$configurationData["AllNodes"] = @($a, $b) | |
Hoge -ConfigurationData $configurationData | |
Start-DscConfiguration -Wait -Force -Verbose Hoge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sample configuration | |
configuration Hoge | |
{ | |
Node localhost | |
{ | |
File Hoge | |
{ | |
Ensure = $Node.Ensure | |
DestinationPath = $Node.DestinationPath | |
Type = 'Directory' | |
} | |
User Hoge | |
{ | |
UserName = "Hoge" | |
Password = $Node.Credential | |
Ensure = 'Present' | |
Disabled = $false | |
} | |
} | |
} | |
$cred = (Get-Credential) | |
# create configurationData | |
$configurationData = New-Object 'System.Collections.Generic.Dictionary[string, hashtable[]]' | |
$a = @{} | |
$a.Add("Credential",$cred) | |
$a.Add("NodeName", "*") | |
$a.Add("PSDSCAllowPlainTextPassword", $true) | |
$a.Add("Ensure", "Present") | |
$a.Add("DestinationPath","c:\fuga") | |
$b = @{} | |
$b.Add("NodeName","localhost") | |
$configurationData["AllNodes"] = @($a, $b) | |
Hoge -ConfigurationData $configurationData | |
Start-DscConfiguration -Wait -Force -Verbose Hoge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Error Message