hi,
I think i do something wrong. I want to execute a powershell script and return the value 0 to SCCM. This does not work. I am not a pro in powershell so probably it has to do something with the script. I have another script, which is working so the settings in my baseline/configuration item must be ok.
Working script (returns also 0):
#discover
$MinDays = 7
(Get-ChildItem C:\windows\ccm\logs | Where-Object { ($_.Name -like 'SCNotify*' -or $_.Name -like 'SCClient*' -or $_.Name -like '_SCNotify*' -or $_.Name -like '_SCClient*') -and ([datetime]$_.LastWriteTime -lt (get-date).adddays(-$MinDays))} |Measure-Object).count
Not working script:
$currentTime = Get-Date -format "dd-MMM-yyyy HH:mm:ss"
Write-Output "$(get-Date) Aktualisierung Vertrauenswürdiger Stammzertifizierungsstellen durchführen..." | Out-file C:\temp\rootcert_neu.txt
cls
try {
# Aktualisierung “Vertrauenswürdige Stammzertifizierungsstellen”
Import-Certificate \\server01.company.de\IT\WURootCert\roots.sst -CertStoreLocation Cert:\LocalMachine\Root
}
catch [system.exception] {
Add-content C:\temp\rootcert_neu.txt "ERROR!!! Aktualisierung Vertrauenswürdiger Stammzertifizierungsstellen fehlgeschlagen"
}
finally { Add-content C:\temp\rootcert_neu.txt "Ende, aktualisierung Vertrauenswürdiger Stammzertifizierungsstellen durchgeführt!!! $currentTime "
}
{ Exit }
write-output 0
Maybe someone can help me. :/
Thank you very much