Szukaj na tym blogu

poniedziałek, 25 kwietnia 2016

Automatically remove computer from SCCM collection based on task sequence success message

 We have some collections called PXE into which we add computers for OSD process. When task sequence finish successfully such computer is removed from this collection automatically using status filter rules.
In SCCM console: Administration > Site configuration > Sites > click on site and from ribbon choose Status Filter Rules

 and


Script can be found here https://drive.google.com/open?id=0B-Myn42Tc3zScDdJRGpOSEhSQlU

piątek, 1 kwietnia 2016

SCCM obsolete uknown computers - abortpxe problem

Recently I tested Windows To Go on some computers which already has SCCM clients installed. It leads me to abortpxe problem - I cannot reimage laptop even if I removed device from SCCM. I search just by name but when using Windows To Go it share the same MAC address as physical computer on which it is running - so this generates for me some unknown or obsolete computers objects. I managed it by creating new collections based on below query

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System where obsolete = 1

Then remove what You need

SCCM application detection method - PowerShell script

I had a situation that we need to run application on workstations (Lenovo ThinInstaller) which install drivers for specific computer model. So it is hard to determine whether this application was run\finished success or not (it is not installed by itself). This application can generate text log file so we decided to build SCCM application detection method based on content of this log file

if (test-path C:\Lenovothinistall.txt) {
$zmienna = gc C:\Lenovothinistall.txt | Select-String "Installation succeeded"
if ($zmienna -ne $null) {write-host "ok"}
}
if (test-path C:\Lenovothinistall.txt) {
$zmienna1 = gc C:\Lenovothinistall.txt | Select-String "Return0Updates"
if ($zmienna1 -ne $null) {write-host "ok"}
}

In such detection method the most important is that PowerShell script should always return 0. SCCM determine whether application was installed successfully or not based on stdout - which in above example is achieved by write-host cmdlet.
More details about this here http://blog.kloud.com.au/2014/08/12/powershell-detection-method-for-sccm-2012-application-compliance-management/