May 7, 2016

PowerShell script SCCM 2012 Agent Install - remotely

$CM12MP='MP.contoso.com'
$CMSiteCode='SR1'
$ErrorActionPreference = "SilentlyContinue"
try
{
#Get ccm cache path for later cleanup...
    try
    {
        $ccmcache = ([wmi]"ROOT\ccm\SoftMgmtAgent:CacheConfig.ConfigKey='Cache'").Location
    } catch {}
#download ccmsetup.exe from MP
    $webclient = New-Object System.Net.WebClient
    $url = "http://$($CM12MP)/CCM_Client/ccmsetup.exe"
    $file = "c:\windows\temp\ccmsetup.exe"
    $webclient.DownloadFile($url,$file) 


Restart Computers Remotely via PowerShell

To restart a remote computer, you need to run the command with credentials that have the right privileges to remotely shut down a computer, typically an admin account. Assuming my current credentials were adequate, I could easily reboot the computer SERVER01:
PS C:\> Restart-Computer Server01 -whatif
What if: Performing operation "Restart-Computer" on Target " (Server01)".
although I didn't really; I took advantage of the -WhatIf parameter to verify my command. This is especially helpful if I'm rebooting a bunch of servers:
PS C:\> restart-computer "server01","server02","server03" -whatif
By the way, here's how you could shut down a list of computers:
PS C:\> restart-computer (get-content c:\work\computers.txt)
Because the cmdlet is using WMI objects and methods under the hood you can specify alternate credentials, either a saved credential object or a user name:
PS C:\> restart-computer (get-content c:\work\computers.txt) -credential "mycompany\administrator"
I'll get prompted for the password, but then this credential will be used for every computer in the list.
The Restart-Computer cmdlet will fail, if a logon session is detected. PowerShell will raise an exception. However, you can force a reboot using -- what else? -- the -force parameter. Be aware this will force applications to close with the potential loss of unsaved work.
Another option for rebooting or even logging off is to use the Win32_OperatingSystem WMI Class and the Win32ShutDown method. I recommend using Invoke-WMIMethod because it supports -WhatIf and -Confirm. I found it just as easy to pipe a WMI object from Get-WMIObject to Invoke-WMIMethod:
PS C:\> Get-WmiObject win32_operatingsystem -ComputerName Quark | Invoke-WMIMethod -name Win32Shutdown
The Win32Shutdown method can accept parameters. The default is 0 which means do a simple logoff. But if the user has open files or if the default method fails, you can always resort to a forceful logoff:
PS C:\> Get-WmiObject win32_operatingsystem -ComputerName Quark | Invoke-WMIMethod -name Win32Shutdown -ArgumentList @(4)

May 6, 2016

Microsoft System Center Operations Manager 2012 Setup and Config

WSUS full guide

SCCM 2012 SP1 Full Installation Step By Step (Remote SQL Method)

SCCM Client Trigger Schedules

The trigger schedule references below are used by the SCCM 2012 Client.

{00000000-0000-0000-0000-000000000001} Hardware Inventory
{00000000-0000-0000-0000-000000000002} Software Inventory
{00000000-0000-0000-0000-000000000003} Discovery Inventory
{00000000-0000-0000-0000-000000000010} File Collection
{00000000-0000-0000-0000-000000000011} IDMIF Collection
{00000000-0000-0000-0000-000000000012} Client Machine Authentication
{00000000-0000-0000-0000-000000000021} Request Machine Assignments
{00000000-0000-0000-0000-000000000022} Evaluate Machine Policies
{00000000-0000-0000-0000-000000000023} Refresh Default MP Task
{00000000-0000-0000-0000-000000000024} LS (Location Service) Refresh Locations Task
{00000000-0000-0000-0000-000000000025} LS (Location Service) Timeout Refresh Task

SCCM Client Repair

http://www.sgautomahjong.sg/media/catalog/category/Repair_Logo_1.jpg 


The following examples can be used to repair the SCCM 2012 R2 client.
When the SCCM Client repair is running, monitor for the running the Windows process “ccmrepair.exe”.

Repair SCCM Client using SCCM Client Command Line:
Local Computer:  C:\Windows\CCM\ccmrepair.exe


Repair SCCM Client using WMIC Command Line:
Local Computer:
WMIC /namespace:\\root\ccm path sms_client CALL RepairClient
Remote Computer:
WMIC /node:[COMPUTER] /namespace:\\root\ccm path sms_client CALL RepairClient
Repair SCCM Client using VBScript: Local Computer:
Set oSCCM = GetObject(“winmgmts:{impersonationLevel=impersonate}!\.\root\ccm:sms_client”)
oSCCM.RepairClient()
Remote Computer:
Set oSCCM = GetObject(“winmgmts:{impersonationLevel=impersonate}!\\[COMPUTER]\root\ccm:sms_client”)
oSCCM.RepairClient()
Repair SCCM Client using Windows PowerShell: Local Computer:
$oSCCM = [wmiclass] “\root\ccm:sms_client”
$oSCCM.RepairClient()
Remote Computer:
$oSCCM = [wmiclass] “\\[COMPUTER]\root\ccm:sms_client”
$oSCCM.RepairClient()

May 5, 2016

wuauclt "Report Now" vs "Detect Now"

When you execute "wuauclt /detectnow", you are telling the computer to seek for new updates. If it is a managed computer (under WSUS or Patch Manager), that's what it'll check against; otherwise it would be Microsoft's Update Servers.

When you execute "wuauclt /reportnow", you are telling the computer to inform the WSUS/Patch Manager server of its update status.

SCCM client uninstall

Remove to manually clean-up all the traces of the client

1. SMS Agent Host Service
2. CCMSetup service (if present)
3. \windows\ccm directory
4. \windows\ccmsetup directory
5. \windows\ccmcache directory
6. \windows\smscfg.ini
7. \windows\sms*.mif (if present)
8. HKLM\software\Microsoft\ccm registry keys
9. HKLM\software\Microsoft\CCMSETUP registry keys
10. HKLM\software\Microsoft\SMS registry keys
11. root\cimv2\sms WMI namespace
12 root\ccm WMI namespace

Microsoft ConfigMgr 2012 – Client Log Files


The most important log files







AppDiscovery.log
Detects installed Application Deployment Types and if deployed Deployment Types are not installed, this log file will show you why (only for the new style ConfigMgr Applications)
AppEnforce.log
will show you the actual command-line executed and the resulting exit code for each Deployment Type (only for the new style ConfigMgr Applications)

AppIntentEval.log
evaluates each Deployment Type’s dependencies and policies (only for the new style ConfigMgr Applications)
AssetAdvisor.log
inventories all installed software (not 100% sure)
CAS.log
Content access service, discovers DPs, download sources and maintains local cache
CCM32BitLauncher.log
logs all command-lines for executed packages (old style ConfigMgr)
CCMEval.log
depends on %windir%ccm\ccmeval.xml and checks the CCM client’s health
CCMEvalTask.log
checks if the CCMEval Task has run
CCMExec.log
monitors the client and CCMExec service
ClientIDManagerStartUp.log
creates and maintains the client’s GUID
ClientLocation.log
determines the assigned ConfigMgr site
CMRcService.log
ConfigMgr Remote Control Service
ContentTransferManager.log
controls BITS or SMB download of ConfigMgr packages
DataTransferService.log
monitors all package downloads
dism.log
monitors dism.exe process during OSD (e.g. driver injection)
EndpointProtectionAgent.log
System Center Endpoint Protection is now integrated into ConfigMgr 2012 and this is its log
ExecMgr.log
logs all deployed packages (old-style) and associated programs and policies
FileSystemFile.log
log for software inventory and file collection
InventoryAgent.log
logs DDRs (Discovery Data Records) for hardware and software
LocationServices.log
finds Management Points, Distribution Points, Software Update Points
MaintenanceCoordinator.log
is in control of all the ConfigMgr client’s maintenance tasks
mtrmgr.log
software metering
oobmgmt.log
Out of Band management, for internet-based clients
PolicyAgent.log
requests policies assigned to machine or user
PolicyAgentProvider.log
monitors any changes to policies
PolicyEvaluator.log
keeps track of new policies
pwrmgmt.log
monitors power management activities on the client
RebootCoordinator.log
collects information about reboots after software update installations
ScanAgent.log
scans the client for need of software updates
SCClient_%domain%@%user%1.log
Software Center Client for a specific domain and user, deployments will show up in here
Scheduler.log
records scheduled ConfigMgr tasks
SCNotify_%domain%@%user%1.log
Software Center Client for a specific domain and user, logs notifications regarding deployments
ServiceWindowManager.log
monitors existing service windows for the client in which for example software is allowed to be installed
smscliui.log
records usage of ConfigMgr UI in system panel
smssha.log
log file for Network Access Protection Agent
smsts.log
Task Sequence log
SoftwareCenterSystemTasks.log
logs Software Center’s process (startup, end)
StateMessage.log
sends software update states to MP
StatusAgent.log
logs events created by ConfigMgr Agent components
SWMTRReportGen.log
generates usage data report
TSAgent.log
logs the process before a TaskSequence starts up, e.g. download of policies
UpdatesDeployment.log
shows information regarding Software Updates, if for example updates are enforced or assigned
UserAffinity.log
new model of “User Device Affinity” (UDA), checks if there is an existing UDA for the machine or creates/sends a new UDA to the MP
















































































Windows Update Agent RESET batch script

This Script allow reset the Windows Update Agent resolving issues with Windows Update.

@ECHO OFF
echo Simple Script to Reset / Clear Windows Update
echo.
PAUSE
echo.
attrib -h -r -s %windir%\system32\catroot2
attrib -h -r -s %windir%\system32\catroot2\*.*
net stop wuauserv
net stop CryptSvc
net stop BITS
ren %windir%\system32\catroot2 catroot2.old
ren %windir%\SoftwareDistribution sold.old
ren "%ALLUSERSPROFILE%\application data\Microsoft\Network\downloader" downloader.old
net Start BITS
net start CryptSvc
net start wuauserv
echo.
echo Task completed successfully...
echo.
PAUSE

WSUS Clean - Powershell script

 This little script will perform a clean up of declined and superceded updates in the WSUS database.  It uses the .Net class "Microsoft.UpdateServices.Administration" assembly, which should be loaded on your WSUS server.  Note that this script will stop the WSUS service twice, but these services will be restarted correctly by the script, and no user action is needed.


$outFilePath = '.\wsusClean.txt' 
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration"| out-null 
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer(); 
$cleanupScope = new-object Microsoft.UpdateServices.Administration.CleanupScope; 
$cleanupScope.DeclineSupersededUpdates = $true        
$cleanupScope.DeclineExpiredUpdates         = $true 
$cleanupScope.CleanupObsoleteUpdates     = $true 
$cleanupScope.CompressUpdates                  = $true 
#$cleanupScope.CleanupObsoleteComputers = $true 
$cleanupScope.CleanupUnneededContentFiles = $true 
$cleanupManager = $wsus.GetCleanupManager(); 
$cleanupManager.PerformCleanup($cleanupScope| Out-File -FilePath $outFilePath 

Hierarchy with CAS

SCCM 2012 Standalone Primary Server Step-by-Step Guides

     

    CCMSETUP Error Codes

    Error CodeMeaning
    0Success
    6Error
    7Reboot Required
    8Setup already running
    9Prerequisite evaluation failure
    10Setup manifest hash validation failure

     

    Upgrade SCCM 2012 R2 SP1 and SCCM 2012 SP2

    Microsoft has released SCCM 2012 R2 SP1 and SCCM 2012 SP2. Now you can download and upgrade your SCCM 2012 and SCCM 2012 R2 infrastructure servers to SCCM 2012 SP2 and SCCM 2012 R SP1. In this post, I’m trying to explain the difference between two installers available for SCCM 2012 SP1 and R2. It seems most of the people (including me) are getting confused about which installer needs to be used to upgrade the existing SCCM 2012 SP1 or R2 environment.

    SCCM 2012 SP2-2



    Before start downloading the SCCM 2012 SP2 installer files (SC2012_SP2_Configmgr_SCEP.exe, SC2012_R2_SP1_Configmgr.exe), you need to understand which installers are actually needed for your existing SCCM 2012 SP1 or R2 environment. You don’t need to download the installer SC2012_R2_SP1_Configmgr to upgrade SCCM 2012 R2 to SCCM 2012 R2 SP1. Rather you may need to download the SC2012_SP2_Configmgr_SCEP.exe. So, the binaries of SCCM 2012 SP2 and SCCM 2012 R2 SP1 are same. More details about this topic is available here in Jason’s post.

    So, what is the reason for having SC2012_R2_SP1_Configmgr.exe (1,128 KB) installer? If you’re a SCCM 2012 SP1 customer and you don’t have R2 features enabled. Now, you are planning enable R2 features then you need to download and install SC2012_R2_SP1_Configmgr.exe.

    SCCM2012R2-SP1

    Johan had tweeted about the confusing error if you download and install “SC2012_R2_SP1_Configmgr.exe” in your existing SCCM 2012 R2 environment.The funny error is “To run this software, the computer must run System Center 2012 Configuration Manager with Service Pack 2.

    Download SC2012_SP2_Configmgr_SCEP.exe (780,310) from here.
    Download SC2012_R2_SP1_Configmgr.exe (1,128 KB) from here.

    More details about the new Features and improvements of SCCM 2012 R2 SP1 and SP2 are available in technet documentation.


    Install SCCM ConfigMgr 1511 RTM

    At last the wait is over, Microsoft released newest version of SCCM /ConfigMgr and this will be known as SCCM/ConfigMgr Current Branch (CB). SCCM CB will get updated every quarter along with Windows 10. It will be called SCCM/ConfigMgr 1511. This version of SCCM won’t be called as SCCM/ConfigMgr 2016 as I mentioned in the previous blog post here (What is the Next Version of SCCM ConfigMgr As A Service). To avoid confusion, I must mention, don’t get confused with SCCM 2016, we don’t know whether there would be something called SCCM 2016 or 2017. This is the current branch of SCCM and this will get updates every 4 months. Download SCCM/ConfigMgr 1511 (not 2016) from MSDN here , Microsoft Evaluation Center and Volume Licensing Service Center.. I installed the SCCM 1511 version in the lab and it has few new options enabled which were not there in SCCM vNext Technical Preview versions. One of them is install SCCM/ConfigMgr CAS (Central Administration Site) server. CAS is not required for most of our organizations as SCCM 1511 primary server can support up to 200000 clients (200K). I’m escaped from CAS now !! What a relief. More details about SCCM 1511 here ConfigMgr team blog.
    SCCM 1511 -RTM-1

    I would suggest to go with single SCCM 1511 primary server if at all your client count is near to 200k as we have an option to add SCCM/ConfigMgr 1511 CAS server afterwards. Following is the option to add CAS into your environment afterwards. The option is called “Join the Primary Site to an existing Hierarchy”.SCCM 1511 -RTM-4Another important point you need to take care during the SCCM 1511 primary/CAS server installation is “Usage Data (telemetry)”. The telemetry (Usage Data) helps SCCM 1511 to collect the data over internet to improve the product quality, installation/upgrade experience of SCCM application. All the usage data send to Microsoft will be encrypted and there won’t be anything from which Microsoft can identify the customer details.  All the data will be hashed. More details in the TechNet article here.SCCM 1511 -RTM-11
    Choose and Control option is there in the above Wizard where you can select the options of usage data like  1. Basic, 2. Enhanced and 3.Full. Basic level data includes data about the SCCM hierarchy, this data will intern help to improve installation and upgrade experience. Example data collected would be site data, operating system version, time zone, Site roles, site numbers, DB performance metrics and details of SCCM features enabled in SCCM site. SCCM 1511 -RTM-18
    Another new feature is to keep SCCM/ConfigMgr updated/up to date by connecting the on prem SCCM infrastructure to ConfigMgr /SCCM cloud service. As I mentioned in the previous blog post here, this will help to upgrade and update SCCM / ConfigMgr environment very easily. SCCM 1511 -RTM-12
    One another important point I’ve noticed with SCCM/ConfigMgr 151 prerequisite checks are :- AD system management container permission related warning (known bug) in pre requisite check seems to be fixed in the latest version of SCCM / ConfigMgr 1511.SCCM 1511 -RTM-13
    This is the famous progress bar of SCCM/ConfigMgr 1511 primary site installation nothing much changes here.SCCM 1511 -RTM-15
     Here we go ! The latest version of System Center Configuration Manager (SCCM/ConfigMgr) 1511.  The version of SCCM/ConfigMgr console is 5.0.8325.1000.SCCM 1511 -RTM-16
    Site version of the latest SCCM/ConfigMgr release 1511 is 5.00.8325.1000SCCM 1511 -RTM-17