Tuesday, 8 August 2017

OS architecture detection script

 
 
 
 
The following script can be used to determine the System architecture

(Use it carefully at your own risk!!)

 
IF /I %PROCESSOR_ARCHITECTURE% EQU x86 (
    msiexec /qn /i 7zip_x86.msi
) ELSE (
    msiexec /qn /i 7zip_x86.msi
)
 
 
**********************************************
 
 
 
 
Option Explicit 
Dim ObjWMI, ColSettings, ObjProcessor 
Dim StrComputer, ObjNetwork 
Set ObjNetwork = WScript.CreateObject("WScript.Network") 
StrComputer = Trim(ObjNetwork.ComputerName) 
Set ObjNetwork = Nothing 
WScript.Echo VbCrLf & "Computer Name: " & StrComputer 
WScript.Echo vbNullString 
Set ObjWMI = GetObject("WINMGMTS:" & "{ImpersonationLevel=Impersonate,AuthenticationLevel=Pkt}!\\" & StrComputer & "\Root\CIMV2") 
Set ColSettings = ObjWMI.ExecQuery ("SELECT * FROM Win32_Processor") 
For Each ObjProcessor In ColSettings 
Select Case ObjProcessor.Architecture 
    Case 0 
        WScript.Echo "Processor Architecture Used by the Platform: x86" 
    Case 6 
        WScript.Echo "Processor Architecture Used by the Platform: Itanium-Based System" 
    Case 9 
        WScript.Echo "Processor Architecture Used by the Platform: x64" 
End Select 
Select Case ObjProcessor.ProcessorType 
    Case 1 
        WScript.Echo "Processor Type: Other. Not in the Known List"     
    Case 2 
        WScript.Echo "Processor Type: Unknown Type" 
    Case 3 
        WScript.Echo "Processor Type: Central Processor (CPU)" 
    Case 4 
        WScript.Echo "Processor Type: Math Processor" 
    Case 5 
        WScript.Echo "Processor Type: DSP Processor" 
    Case 6 
        WScript.Echo "Processor Type: Video Processor" 
End Select 
WScript.Echo "Processor: " & ObjProcessor.DataWidth & "-Bit" 
WScript.Echo "Operating System: " & ObjProcessor.AddressWidth & "-Bit" 
WScript.Echo vbNullString     
If ObjProcessor.Architecture = 0 AND ObjProcessor.AddressWidth = 32 Then 
    WScript.Echo "This Machine has 32 Bit Processor and Running 32 Bit OS" 
End If 
If (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 32 Then 
    WScript.Echo "This Machine has 64-Bit Processor and Running 32-Bit OS" 
End If 
If (ObjProcessor.Architecture = 6 OR ObjProcessor.Architecture = 9) AND ObjProcessor.DataWidth = 64 AND ObjProcessor.AddressWidth = 64 Then 
    WScript.Echo "This Machine has 64-Bit Processor and Running 64-Bit OS" 
End If 
Next 
Set ObjProcessor = Nothing:    Set ColSettings = Nothing:    Set ObjWMI = Nothing:    StrComputer = vbNullstring 

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. 
Manufacturer
Model
Serial Number
CPU
HDD Capacity/Free space
OS incl. Service Pack
RAM
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

Clear-Host
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 = "www.sccmrookie.blogspot.com"

If PingSite( strWebsite ) Then
    WScript.Echo "Web site " & strWebsite & " is up and running!"
Else
    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

    objHTTP.Send
    intStatus = objHTTP.Status

    On Error Goto 0

    If intStatus = 200 Then
        PingSite = True
    Else
        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:

SELECT 
dbo.v_RA_System_MACAddresses.MAC_Addresses0,
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.ResourceType,
R.Name,R.SMSUniqueIdentifier,
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
ORDER BY SystemCount DESC


Monday, 6 February 2017

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








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 ,
SMS_G_System_LOGICAL_DISK.FreeSpace,
SMS_G_System_LOGICAL_DISK.Size
from 
SMS_R_System 
inner join SMS_G_System_LOGICAL_DISK on SMS_G_System_LOGICAL_DISK.ResourceID = SMS_R_System.ResourceId

where
SMS_G_System_LOGICAL_DISK.FreeSpace < 5000