• 20Apr

    Below I’ve built this custom script that will completely remove the SCCM Client and wait until all processes have stopped. Once it’s uninstalled it will also remove any residual files left from a previous install and then run a fresh install of the client. In order for this script to work you must place it in the same directory as the setup files for the SCCM client. Then open up a PowerShell prompt as an Administrator and type the following command:
    PowerShell.exe -ExecutionPolicy ByPass ".\Invoke-SCCM-Client-Install.ps1" -Wait

    The following values have to be amended to work in your environment:
    "ccmsetup.exe /forceinstall /mp:[SCCM SERVER NAME] INSTALL=ALL SMSPROVISIONINGMODE=1 SMSSITECODE=[SCCM SITE CODE] FSP=[Fallback Status Point Name -- Optional Switch] /NoCRLCheck"

    After the script runs you can keep track of the script process by opening another PowerShell window and typing the following command:
    Get-Content $env:SystemRoot\System32\LogFiles\OSD\SCCM-Client\[Press "Tab" Key for LogFile Name] -Wait


    # Script: Invoke-SCCM-Client-Install.ps1
    # Description: Uninstalls current SCCM Client and Installs new Client.
    # Execution: PS> PowerShell.exe -ExecutionPolicy ByPass ".\Invoke-SCCM-Client-Install.ps1" -WindowStyle Hidden -Wait
    # Author: Harry Caskey // harrycaskey@gmail.com // www.harrycaskey.com
    # Last Modified: 2017-04-20
    #
    $logPath = "$env:SystemRoot\System32\LogFiles\OSD\SCCM-Client"
    New-Item -Path $logPath -Type Directory -Force | Out-Null
    $timeDate = Get-Date -Format "yyyyMMdd-HHmmss"
    $logFileName = $env:COMPUTERNAME + "_" + $timeDate
    #
    New-Item -Path $logPath -Type Directory -Force | Out-Null
    #
    #
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    #
    #
    if ($procMsiExec -or $procCCMExec -or $procCCMSetup) {
    Stop-Service -Name CcmExec -Force | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    "Processess have been stopped. Executing ccmsetup.exe /uninstall command..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "/uninstall" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 15
    do {
    Start-Sleep 10
    "Uninstall is running..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMExec -eq $null) -and ($procCCMSetup -eq $null))
    "Uninstaller has completed..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    }
    else {
    "No processess are currently started. Executing the uninstaller now..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "/uninstall" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 15
    do {
    Start-Sleep 10
    "Uninstall is running..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMExec -eq $null) -and ($procCCMSetup -eq $null))
    Remove-Item $env:SystemRoot\CCM, $env:SystemRoot\ccmsetup, "$env:SystemDrive\ProgramData\Microsoft\Windows\Start Menu\Programs\Microsoft System Center" -Recurse -Force -ErrorAction Ignore
    Remove-Item HKLM:\SOFTWARE\Microsoft\CCMSetup -Force -ErrorAction Ignore
    "SCCM Client removed..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    }
    #
    #
    Start-Sleep -Seconds 15
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMExec = Get-Process -Name ccmexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    #
    #
    "Starting SCCM Client install..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Process "ccmsetup.exe" -ArgumentList "ccmsetup.exe /forceinstall /mp:[SCCM SERVER NAME] INSTALL=ALL SMSPROVISIONINGMODE=1 SMSSITECODE=[SCCM SITE CODE] FSP=[Fallback Status Point Name -- Optional Switch] /NoCRLCheck" -Wait | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    do {
    Start-Sleep 10
    "Installing SCCM Client..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procMsiExec = Get-Process -Name msiexec -ErrorAction SilentlyContinue
    $procCCMSetup = Get-Process -Name ccmsetup -ErrorAction SilentlyContinue
    Start-Sleep 5
    }
    until (($procMsiExec -eq $null) -and ($procCCMSetup -eq $null))
    Start-Sleep 120
    #
    Restart-Service -Name CcmExec
    Start-Sleep 120
    #
    # Machine Policy Retrieval Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000021}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Machine Policy Evaluation Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000022}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Application Deployment Evaluation Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000121}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # State Message Refresh
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000111}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    # Hardware Inventory Cycle
    Invoke-WMIMethod -Namespace root\ccm -Class SMS_CLIENT -Name TriggerSchedule "{00000000-0000-0000-0000-000000000001}" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    Start-Sleep 10
    #
    #
    "Finished installing SCCM Client..." | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force
    $procCCMExec = Get-Process -Name ccmexec
    $procCCMExecStatus = $procCCMExec.ProcessName
    if ($procCCMExecStatus) {"CCMExec: Enabled" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force}
    else {"CCMExec: Disabled" | Out-File -FilePath $logPath\$logFileName.log -Append -Encoding ascii -Force}
    # Clean Up Process
    Remove-Variable procMsiExec, procCCMExec, procCCMSetup, logPath, logFileName -Force

  • 06Apr

    If you noticed Microsoft has taken away the default Windows Photo Viewer in Windows 10.  This can be quite annoying for it you want to just open one photo that isn’t meant to be stored in a photo library.  I found this trick online and wanted to share it.  If you have gone looking in your “Program Files” folder looking for this application you won’t find it.  Technically this is a COM surrogate application and must be called using the Run DLL executable (rundll32.exe).  If you need to script this COM application and would like to know the program location you can also run the following command:

    %SystemRoot%\System32\rundll32.exe "%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen [Optional] [Path to Image File]

    To add this feature back into Windows 10 you must add the following registry keys and then set this COM application to be the default photo viewer.

    Registry Keys: Turn on Windows Photo Viewer (Zip) / Turn on Windows Photo Viewer (Text File)

    Registry-Key

    Open-With

    Always-With

     

    Tags: ,

  • 25Nov

    RDP Disconnect ErrorI encountered this error when trying to update group policy on a remote machine.  I kept getting disconnected and it’s very frustrating reconnecting after every gpupdate.  I found this tweak that will resolve this issue.

    When group policy is refreshed the policy settings are deleted and then reset.  During this time the configuration on the remote machine is temporarily valid.  Which then all sessions may be disconnected.

    You can apply this setting via Group Policy or via command line:

    To Add/Update:
    PS: New-Item -Type DWord -Path HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\fDenyTSConnections  -Value "0" -Force
    CMD: REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server /v fDenyTSConnections /t REG_DWORD /d 0 /f

    To Verify:
    PS: Test-Path -Path HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\fDenyTSConnections
    CMD: REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server /v fDenyTSConnections

     

    Ref: http://support.microsoft.com/kb/2083411

  • 07Oct

    IPv6 InterfaceIPv6 can cause some problems for applications that are not configured to use IPv6. By default IPv6 is enabled with Windows, disabling it can be tricky because even after you deselect Internet Protocol Version 6 (TCP/IPv6)” in the connection properties of your device it still doesn’t disable all IPv6 components. You can verify this by running ipconfig /all. Therefore to truly disable IPv6 you have to modify the following keys in the registry.

    First I would suggest running this PowerShell command to un-check the IPv6 setting on all your network adapters, if you’d like to select just one particular you can use the “Get-NetAdapterBinding” command to get the “-Name” value for the adapter you wish to set.

    It’s important to note that this command will un-check all “Internet Protocol Version 6 (TCP/IPv6)” settings from all adapters.

    PS: Set-NetAdapterBinding -Name “*” -DisplayName “Internet Protocol Version 6 (TCP/IPv6)” -ComponentID “ms_tcpip6” -Enabled $false

    After you’ve completed this command I would recommend running “Get-NetAdapterBinding” and see if “ms_tcpip6” is set to “False”.  If so continue on to truly disable IPv6.

    Now in the Registry Editor (regedit.exe), locate and then click the following registry subkey:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\

    DisabledComponents
    REG_DWORD: 0xff

    Other value options you might want to consider are:

    0 to re-enable all IPv6 components (Windows default setting).
    0xff to disable all IPv6 components except the IPv6 loopback interface. This value also configures Windows to prefer using IPv4 over IPv6 by changing entries in the prefix policy table. For more information, see Source and destination address selection.
    0x20 to prefer IPv4 over IPv6 by changing entries in the prefix policy table.
    0x10 to disable IPv6 on all non-tunnel interfaces (both LAN and Point-to-Point Protocol [PPP] interfaces).
    0x01 to disable IPv6 on all tunnel interfaces. These include Intra-Site Automatic Tunnel Addressing Protocol (ISATAP), 6to4, and Teredo.
    0x11 to disable all IPv6 interfaces except for the IPv6 loopback interface.

    If you are trying to disable IPv6 completely I would recommend “0xff” because this value also configures windows to prefer IPv4 over IPv6.

    You can apply this setting via Group Policy or via command line:

    To Add/Update:
    PS: New-Item -Type DWord -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents -Value “0xff” -Force
    CMD: REG ADD HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents /t REG_DWORD /d 0xff /f

    To Verify:
    PS: Test-Path -Path HKLM:\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters\DisabledComponents
    CMD: REG QUERY HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip6\Parameters /v DisabledComponents

    After you’ve applied this key you must reboot the system for it to completely take effect.

     

    Ref: https://support2.microsoft.com/kb/929852

  • 06Oct

    The profile for the user is a temporary profile

    When installing an application you get this error message “The profile for the user is a temporary profile”. This happens after installing a security update: MS14-049. This update affects the execution process of the Windows Installer. To bypass this, set the following registry key and it will ignore this prompt and continue with the installation.

    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer\

    SecureRepairPolicy
    REG_DWORD: 1

    You can apply this setting via Group Policy or via command line:

    To Add:
    PS: New-Item -Type DWord -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer\SecureRepairPolicy -Value “1” -Force
    CMD: REG ADD HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer /v SecureRepairPolicy /t REG_DWORD /d 1 /f

    To Verify:
    PS: Test-Path -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer\SecureRepairPolicy
    CMD: REG QUERY HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\Installer /v SecureRepairPolicy

    Another option is that you can add the software GUID’s to a whitelist reference is listed below.
    Ref: https://support2.microsoft.com/kb/2918614

« Previous Entries   

-->