The program disables the feature "internet Explorer 11 after looping through a list of servers and exports the results to a csv file with Server Names and the "state" of the Internet explorer as columns as shown below but value component does not show up in the resulting csv file, specifically this value : $Status
ServerName State
genericNameServer It is supposed to be either "disabledPending or "Unknown", but it stays blank
#Filter the list of servers based on the input parameters (filtering in this location prevents having to loop through servers that are not being processed)
$FilteredServers = $AllServers | Where-Object { ($PSItem.OS -like "*$OperatingSystem*") -and ($PSItem.Type -eq $Type) -and ($PSItem.Citrix -eq $False)}
#Iterate through the list of servers
foreach ($Server in $FilteredServers)
#if the server is 2012/2016
elseif ((($OperatingSystem -eq '2012') -or ($OperatingSystem -eq '2016')))
{
Invoke-Command -ComputerName ($Server.ServerName) -ScriptBlock {
#Disable IE
dism /online /Disable-Feature /FeatureName:Internet-Explorer-Optional-amd64 /NoRestart
#Get the Interenet Exploere feature
$IEStatus = Get-WindowsOptionalFeature -Online -FeatureName Internet-Explorer-Optional-amd64
}
# evaluate if state property is disabledpending or not and create a variable called Status with a value of either 'disablepending' or 'status: unknown'
if ($IEStatus.State -eq 'DisablePending') { $Status = 'DisablePending' }
else { $Status = 'Unknown' }
}
$CsvStatus += [PSCustomObject]@{
ServerName = $Server.ServerName
State = ($Status)
}
}
}
$CsvStatus | Export-Csv -Path c"\tem\effectedServer.csv