|
|
@ -47,15 +47,34 @@ Elseif (!$params.state) {
|
|
|
|
If ($params.restart) {
|
|
|
|
If ($params.restart) {
|
|
|
|
$restart = $params.restart | ConvertTo-Bool
|
|
|
|
$restart = $params.restart | ConvertTo-Bool
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$restart = $false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($params.include_sub_features)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$includesubfeatures = $params.include_sub_features | ConvertTo-Bool
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$includesubfeatures = $false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($params.include_management_tools)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$includemanagementtools = $params.include_management_tools | ConvertTo-Bool
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$includemanagementtools = $false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
If ($state -eq "present") {
|
|
|
|
If ($state -eq "present") {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if ($restart) {
|
|
|
|
$featureresult = Add-WindowsFeature -Name $name -Restart:$restart -IncludeAllSubFeature:$includesubfeatures -IncludeManagementTools:$includemanagementtools
|
|
|
|
$featureresult = Add-WindowsFeature -Name $name -Restart
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
$featureresult = Add-WindowsFeature -Name $name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
catch {
|
|
|
|
Fail-Json $result $_.Exception.Message
|
|
|
|
Fail-Json $result $_.Exception.Message
|
|
|
@ -63,12 +82,7 @@ If ($state -eq "present") {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Elseif ($state -eq "absent") {
|
|
|
|
Elseif ($state -eq "absent") {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
if ($restart) {
|
|
|
|
$featureresult = Remove-WindowsFeature -Name $name -Restart:$restart
|
|
|
|
$featureresult = Remove-WindowsFeature -Name $name -Restart
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
$featureresult = Remove-WindowsFeature -Name $name
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch {
|
|
|
|
catch {
|
|
|
|
Fail-Json $result $_.Exception.Message
|
|
|
|
Fail-Json $result $_.Exception.Message
|
|
|
|