Hi Team
I just came across this script in tech gallery and wanted to understand one specific thing
https://gallery.technet.microsoft.com/scriptcenter/Windows-Service-Compare-51eeb1ec#content
if (!(Test-Path .$XmlNameBefore)) {
Write-Host "(BEFORE)" -ForegroundColor Green -NoNewline
Write-Host " Connecting to $Computer..." -NoNewline
try {
get-wmiobject win32_service -ComputerName $Computer -ErrorAction Ignore | select SystemName,Name,DisplayName,State,StartMode | sort StartMode | Export-Clixml .\$XmlNameBefore
if ($?) {Write-Host "Success" -ForegroundColor Green}
else {
Write-Host "WMI connection failed" -ForegroundColor Red
Remove-Item .\$XmlNameBefore -recurse
}
I understand most of the code but except 1 thing.
if ($?) {Write-Host "Success" -ForegroundColor Green}
What is "$?" here referring to in the above if statement?
can some one please help me understand this "$?"