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