Wednesday, 31 May 2017

Disable Java Update Batch file.

This simple .bat file can be used to disable Java automatic updates:

@echo off

rem disable java update by policy
reg add "HKLM\SOFTWARE\JavaSoft\Java Update\Policy" /V EnableJavaUpdate /T REG_DWORD /D 0 /F
if defined programfiles(x86) reg add "HKLM\SOFTWARE\Wow6432Node\JavaSoft\Java Update\Policy" /V EnableJavaUpdate /T REG_DWORD /D 0 /F

REM Remove java update scheduler
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "SunJavaUpdateSched" /f
if defined programfiles(x86) reg delete "HKLM\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run" /v "SunJavaUpdateSched" /f

REM kill java updater if started
taskkill /IM jucheck.exe /F
taskkill /IM juscheck.exe /F

exit 0

Monday, 1 May 2017

Powershell Script to Get remote computer system and hardware information

Uses PowerShell with the WMI cmdlets to report the following details of a list of devices on your network. 
Serial Number
HDD Capacity/Free space
OS incl. Service Pack
Logged in user
Last reboot
Make sure you change the list of computer names in the HOSTNAME array to match your devices (Line 5)
Results are displayed in the console window but could be easily modified to push it into a CSV file

# Remote System Information
# Shows hardware and OS details from a list of PCs
# Thom McKiernan 22/08/2014

$ArrComputers =  ".", "HOSTNAME"
#Specify the list of PC names in the line above. "." means local system

foreach ($Computer in $ArrComputers) 
    $computerSystem = get-wmiobject Win32_ComputerSystem -Computer $Computer
    $computerBIOS = get-wmiobject Win32_BIOS -Computer $Computer
    $computerOS = get-wmiobject Win32_OperatingSystem -Computer $Computer
    $computerCPU = get-wmiobject Win32_Processor -Computer $Computer
    $computerHDD = Get-WmiObject Win32_LogicalDisk -ComputerName $Computer -Filter drivetype=3
        write-host "System Information for: " $computerSystem.Name -BackgroundColor DarkCyan
        "Manufacturer: " + $computerSystem.Manufacturer
        "Model: " + $computerSystem.Model
        "Serial Number: " + $computerBIOS.SerialNumber
        "CPU: " + $computerCPU.Name
        "HDD Capacity: "  + "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
        "HDD Space: " + "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size) + " Free (" + "{0:N2}" -f ($computerHDD.FreeSpace/1GB) + "GB)"
        "RAM: " + "{0:N2}" -f ($computerSystem.TotalPhysicalMemory/1GB) + "GB"
        "Operating System: " + $computerOS.caption + ", Service Pack: " + $computerOS.ServicePackMajorVersion
        "User logged In: " + $computerSystem.UserName
        "Last Reboot: " + $computerOS.ConvertToDateTime($computerOS.LastBootUpTime)

Thursday, 6 April 2017

VBS script to check if a site is up and running

Dim strWebsite

strWebsite = ""

If PingSite( strWebsite ) Then
    WScript.Echo "Web site " & strWebsite & " is up and running!"
    WScript.Echo "Web site " & strWebsite & " is down!!!"
End If

Function PingSite( myWebsite )
' This function checks if a website is running by sending an HTTP request.
' If the website is up, the function returns True, otherwise it returns False.
' Argument: myWebsite [string] in "www.domain.tld" format, without the
' "http://" prefix.

    Dim intStatus, objHTTP

    Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )

    objHTTP.Open "GET", "http://" & myWebsite & "/", False
    objHTTP.SetRequestHeader "User-Agent", "Mozilla/4.0 (compatible; MyApp 1.0; Windows NT 5.1)"

    On Error Resume Next

    intStatus = objHTTP.Status

    On Error Goto 0

    If intStatus = 200 Then
        PingSite = True
        PingSite = False
    End If

    Set objHTTP = Nothing
End Function

Wednesday, 1 March 2017

How to find duplicate objects in SCCM

Following you have some useful reports to be able to deal with duplicated objects in SCCM:
Duplicate MAC Addresses.
I normally see this in environments where VDI is common. Generally, a VDI admin has duplicated machines without giving each a unique MAC address. This is bad and should be avoided. If you’re VDI admin has created a bunch of computers with the same MAC, we need to delete them from SCCM. To find these objects, run the following TSQL query:

Count(dbo.v_R_System.Name0) AS SystemCount 
FROM dbo.v_R_System RIGHT OUTER JOIN dbo.v_RA_System_MACAddresses 
ON dbo.v_R_System.ResourceID = dbo.v_RA_System_MACAddresses.ResourceID 
GROUP BY dbo.v_RA_System_MACAddresses.MAC_Addresses0 ORDER BY SystemCount DESC
Duplicate Computer Names.
These are the most common duplicate objects. Most likely this occurs due to OSD or conflicting discovery cycles. We basically end up with two computer objects, with the same name/hardware/MAC but different SMSBIOSGUID. It causes much confusion for ConfigMgr because it often doesn’t know how to process the inventory for the phantom object. To find these objects, create an SCCM Query (or query based collection) with the following Query Statement:

select R.ResourceID,
R.ResourceDomainORWorkgroup,R.Client from SMS_R_System as r 
full join SMS_R_System as s1 on s1.ResourceId = r.ResourceId 
full join SMS_R_System as s2 on s2.Name = s1.Name 
where s1.Name = s2.Name and s1.ResourceId != s2.ResourceId

Duplicate HardwareID’s
One other way to look for dupes is to use the HardwareID. Use the following TSQL to find the objects with duplicate HardwareIDs:

SELECT Name0, Hardware_ID0, Count(Hardware_ID0) AS SystemCount
FROM dbo.v_R_System
GROUP BY Hardware_ID0, Name0

Monday, 6 February 2017

Query for Workstations with low disk space (less than 5GB)

inner join SMS_G_System_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId

SMS_G_System_LOGICAL_DISK.FreeSpace < 5000

Tuesday, 3 January 2017

CcmSetup failed with error code 0x80070307 Windows 10

CcmSetup failed with error code 0x80070307

When testing the latest Build of Windows 10 I got an error installing the Configuration Manager 2012 R2 client, it fails installing the Windows Update agent with the following error in the CCMSetup.log file.

“File ‘C:\WINDOWS\ccmsetup\WindowsUpdateAgent30-x64.exe’ returned failure exit code 775. Fail the installation.”

I assume a solution to this error will presented soon, but I cannot wait to get started with my testing of 10049 so installing the SCCM Client with the following command line solves at least the installation error of the Configuration Manager client.

- ccmsetup.exe  /skipprereq:WindowsUpdateAgent30-x86.exe

- ccmsetup.exe  /skipprereq:WindowsUpdateAgent30-x64.exe

Then ccmsetup.exe will skip the installation of the Windows Update Agent and continue the installation anyway. Normally I use the /Skipprereq: command to skip the installation of Silverlight on servers as I don’t want Silverlight installed on my servers. But the command line works great in this case as well.

You will then see this in the ccmsetup.log file on the client which shows that the installation of the Windows Update agent was skipped and that the installation continues.

“Item ‘x64/WindowsUpdateAgent30-x64.exe’ is excluded by the ‘/skipprereq:’ switch. Ignore it.”

God Luck with the testing of Windows 1o!

Update: SCCM 2012 SP2 and SCCM 2012 R2 Sp1 solves the problem so to solve the issue and get OSD working an upgrade is needed. If you just want the client to work and cannot upgrade now, the workaround is valid for newer releases of Windows 10 as well