07 August 2014

List of client "Installation Error"

When troubleshooting client health in SCCM 2012, looking into "Push Information" you will find "Last Installation Error".
Here is a list of known errors, to help identifying and solving the issues.




2 The system cannot find the file specified.
5 Access denied.
52 You were not connected because a duplicate name xists on the network. Make sure there is not a duplicate name in DNS and that 2 machines don’t have the same IP in DNS.
53 Unable to locate – http://support.microsoft.com/kb/920852 – cannot connect to admin$ – Computer Browser not started – add File/print sharing to Exceptions in Firewall – turn file and print on.
58 The specified server cannot perform The requested operation
64 The specified network name is no longer available. Source: Windows
67 Network name cannot be found.
86 Network password is not correct? Machine Name <> resolved name.
112 Not enough disk space
1003 Cannot complete this function.
1053 The service did not respond to the start or control request in a timely fashion.
1068 The dependency service or group failed to start
1130 Not enough server storage is available to process this command. Source: Windows
1203 The network path was either typed incorrectly, does not exist, or the network provider is not currently available. Please try retyping the path or contact your network administrator.
An extended error has occurred. Source: Windows
1305 The revision level is unknown.
1396 Logon Failure: The target account name is incorrect. (NBTSTAT -a reverse lookup, duplicate IP address).
1450 Insufficient system resources exist to complete the requested service. Source: Windows
1789 The trust relationship between this workstation and the primary domain failed
2147023174 The RPC server is unavailable.
2147024891 Access is denied
2147749889 Generic WMI failure (Broken WMI).
2147749890 Not found – Source: Windows Management (WMI) – try repair WMI.
2147749904 Invalid class – Source: Windows Management (WMI).
2147749908 Initialization failure – Source: Windows Management (WMI).
2147942405 Access is Denied (Firewall rule? / MacAfee-HIPS?).
2147944122 The RPC server is unavailable. (Dcom is miss-configured for security (http://support.microsoft.com/kb/899965).
2148007941 Server Execution Failed.


Hope this will help you on your way.

29 July 2014

POSH script to return compliancy based on collection in SCCM 2012 R2

For our Operations department, I have created a script that returns LastReboot, RebootPending and Compliancy for servers in a collection.





You execute the script with collection id as input. Output can be formatted by powershell:


PS> .\SUcompl.ps1 | Format-Table -AutoSize


ie:
d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | FT -AutoSize d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | sort-object -property RebootPending | FT -AutoSize d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | Export-Csv report.csv -NoTypeInformation

here is the script:

<#
.SYNOPSIS
Gets the pending reboot status on computers in a sccm 2012 collection.

.DESCRIPTION
Based on a sccm 2012 collection id, pending reboot status is returned for each member in the collection.

.PARAMETER sccm collection id
The sccm 2012 Collection ID.

.EXAMPLE
PS \SUcompl.ps1 | Format-Table -AutoSize

d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | FT -AutoSize
d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | sort-object -property RebootPending | FT -AutoSize
d:\SCCM_scripts\SUcompl.ps1 MDT000B1 | Export-Csv report.csv -NoTypeInformation

.NOTES
Author: Bill Bjerrum
Email: billbjerrum@gmail.com
Date: 28-07-2014
Ver.: 1.00
#>
#Set required Input Parameters
Param(
[string]$CollID
)
If($CollID){}
else{
Write-Host"Required Input is missing! Collection ID."
exit
}

#Import ConfigMgr PS Module
Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1"

#Get the CMSITE SiteCode
$SiteCode = Get-PSDrive -PSProvider CMSITE
Push-Location $SiteCode":"

$ComputerList = Get-CMDevice -CollectionId $CollID | Select -Property Name,ClientType

ForEach ($Computer In $ComputerList){
if ($Computer.ClientType -eq 1) {
$CBSRebootPend = $null
$PendFileRename,$Pending,$SCCM = $false,$false,$false
$WMI_OS = Get-WmiObject Win32_OperatingSystem -ComputerName $Computer.Name
$LastReboot=$WMI_OS.ConvertToDateTime($WMI_OS.lastbootuptime)

# Making registry connection to the local/remote computer
$RegCon = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]"LocalMachine",$Computer.Name)
# If Vista/2008 & Above query the CBS Reg Key
If ($WMI_OS.BuildNumber -ge 6001) {
$RegSubKeysCBS = $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\").GetSubKeyNames()
$CBSRebootPend = $RegSubKeysCBS -contains "RebootPending"
}

# Query WUAU from the registry
$RegWUAU = $RegCon.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\")
$RegWUAURebootReq = $RegWUAU.GetSubKeyNames()
$WUAURebootReq = $RegWUAURebootReq -contains "RebootRequired"

# Query PendingFileRenameOperations from the registry
$RegSubKeySM = $RegCon.OpenSubKey("SYSTEM\CurrentControlSet\Control\Session Manager\")
$RegValuePFRO = $RegSubKeySM.GetValue("PendingFileRenameOperations",$null)

# Closing registry connection
$RegCon.Close()

#If PendingFileRenameOperations has a value set $RegValuePFRO variable to $true
If ($RegValuePFRO) {
$PendFileRename = $true
}

$CCMClientSDK = $null
$CCMSplat = @{
NameSpace='ROOT\ccm\ClientSDK'
Class='CCM_ClientUtilities'
Name='DetermineIfRebootPending'
ComputerName=$Computer.Name
ErrorAction='SilentlyContinue' }
$CCMClientSDK = Invoke-WmiMethod @CCMSplat
If ($CCMClientSDK) {
If ($CCMClientSDK.ReturnValue -ne 0) {
Write-Warning "Error: DetermineIfRebootPending returned error code $($CCMClientSDK.ReturnValue)"
}

If ($CCMClientSDK.IsHardRebootPending -or $CCMClientSDK.RebootPending) {
$SCCM = $true
}
}
Else {
$SCCM = $null
}

# If any of the variables are true, set $Pending variable to $true
If ($CBSRebootPend -or $WUAURebootReq -or $SCCM -or $PendFileRename) {
$Pending = $true
}

$UpdateAssigment = Get-WmiObject -Query "Select * from CCM_AssignmentCompliance" -Namespace root\ccm\SoftwareUpdates\DeploymentAgent -ComputerName $Computer.Name
If($UpdateAssigment) {
$IsCompliant = $true
$MDTCompliant = $true
$UpdateAssigment | ForEach-Object{
if($_.IsCompliant -eq $false){$MDTCompliant = $false}
}
}

# Creating Custom PSObject and Select-Object Splat
$SelectSplat = @{
Property=('Computer','OperatingSystem','LastReboot','RebootPending','Compliant')
}
New-Object -TypeName PSObject -Property @{
Computer=$WMI_OS.CSName
OperatingSystem=$WMI_OS.Caption
LastReboot=$LastReboot
RebootPending=$Pending
Compliant=$MDTCompliant
} | Select-Object @SelectSplat

#Write-Host $Computer.Name, $WMI_OS.Caption, $LastReboot, $Pending
}

}
Pop-Location