SCCM 2012

From Slothx.net

Jump to: navigation, search

Contents

General

Download components: SMSSETUP\BIN\X64\SetupDL.exe <path>

add-windowsfeature powershell-ise

Webcasts

PDT

Diskpart in OSD

Policy Diagnostics

Forum Posts

reg add HKLM\Software\Microsoft\CCM /v UserPolicyReRequestDelay /t REG_DWORD /d 6000000
reg add HKLM\Software\Microsoft\CCM /v UserPolicyReRequestDelay /t REG_DWORD /d 1000000

Policy Check

exec MP_GetMachinePolicyAssignments 'GUID:B6129BFD-49D7-4D3F-BED7-31F29C806FFF',NULL
SELECT Name0, SMBIOS_GUID0, SMS_Unique_Identifier0, Active0, Client0, Client_Version0, Decommissioned0, Is_Virtual_Machine0, Obsolete0 FROM v_R_System WHERE (Name0 LIKE 'X%')

SCCM 2012 Forums

Secure Boot

Downloads

APP-V

Reporting


To User: @UserSIDs from SQL Management Studio substitute "disabled" instead.

Example:
select * from fn_rbac_Package("disabled") 

-----------

select * from fn_ListLatestApplicationCIs(1033)

Select Manufacturer, DisplayName, SoftwareVersion, CI_UniqueID, ModelID, SDMPackageVersion, DateCreated, LastModifiedBy from fn_ListLatestApplicationCIs(1033)

SELECT     app.Manufacturer, app.DisplayName, app.SoftwareVersion, dt.DisplayName AS DeploymentTypeName, dt.PriorityInLatestApp, dt.Technology
FROM         dbo.fn_ListDeploymentTypeCIs(1033) AS dt INNER JOIN
dbo.fn_ListLatestApplicationCIs(1033) AS app ON dt.AppModelName = app.ModelName
WHERE     (dt.IsLatest = 1)

SELECT    DISTINCT app.Manufacturer, app.DisplayName, app.SoftwareVersion, dt.DisplayName AS DeploymentTypeName, dt.PriorityInLatestApp, dt.Technology,
v_ContentInfo.ContentSource, v_ContentInfo.SourceSize
FROM         dbo.fn_ListDeploymentTypeCIs(1033) AS dt INNER JOIN
dbo.fn_ListLatestApplicationCIs(1033) AS app ON dt.AppModelName = app.ModelName LEFT OUTER JOIN
v_ContentInfo ON dt.ContentId = v_ContentInfo.Content_UniqueID
WHERE     (dt.IsLatest = 1)

Distribution

Content Distribution Priorities

KB Articles

SCCM 2012 OSD Prestage

Office Activation

Activation Command lines:

cmd line:
cscript.exe "C:\Program Files (x86)\Microsoft Office\Office14\ospp.vbs" /act

path:
C:\Program Files\Microsoft Office\Office14

SCCM Client Actions

PowerShell: Trigger ConfigMgr client action ( ScheduleID) 
If you’re an SCCM admin you often need to trigger actions on a remote client.  There are many ways to accomplish this.  Following is a simple way to accomplish with PowerShell.

First you need the ID of the schedule you’d like to kick off. They are all documented in ConfigMgr 2012 Toolkit SP1.  Both in the help document but also in the SendScheduleMessages.xml.  Per that file, there are 49 different ScheduleIDs (I’ve listed them all below in a table as well).

But who wants to lookup up the ID every time and type it in?  Not me.  

The following simple PowerShell script below will:

•Get all the IDs from the SendScheduleMessages.xml file (So you need to have the ConfigMgr 2012 Toolkit SP1 installed)
•Display all the available ScheduleIDs in a GridView
•
•Simply Pick the ScheduleID you want to Run and Press OK
•The script will then ask you for the computer name, type it in and press enter
•
•That’s it…..
 

PowerShell
([xml](gc "C:\Program Files (x86)\Configmgr 2012 Toolkit SP1\ClientTools\SendScheduleMessages.xml")).Messages.Message.Guid | Out-GridView -PassThru |`
%{$result=Invoke-WmiMethod -ComputerName (Read-Host "Computer") -Namespace root\ccm -Class sms_client -Name TriggerSchedule $_.Id;"Ran $($_.DisplayName) on $($result.PSComputerName)"}
1
2 ([xml](gc "C:\Program Files (x86)\Configmgr 2012 Toolkit SP1\ClientTools\SendScheduleMessages.xml")).Messages.Message.Guid | Out-GridView -PassThru |`%{$result=Invoke-WmiMethod -ComputerName (Read-Host "Computer") -Namespace root\ccm -Class sms_client -Name TriggerSchedule $_.Id;"Ran $($_.DisplayName) on $($result.PSComputerName)"} 
 

List of ScheduleIDs:

ID DisplayName 
{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 
{00000000-0000-0000-0000-000000000026} Policy Agent Request Assignment (User) 
{00000000-0000-0000-0000-000000000027} Policy Agent Evaluate Assignment (User) 
{00000000-0000-0000-0000-000000000031} Software Metering Generating Usage Report 
{00000000-0000-0000-0000-000000000032} Source Update Message 
{00000000-0000-0000-0000-000000000037} Clearing proxy settings cache 
{00000000-0000-0000-0000-000000000040} Machine Policy Agent Cleanup 
{00000000-0000-0000-0000-000000000041} User Policy Agent Cleanup 
{00000000-0000-0000-0000-000000000042} Policy Agent Validate Machine Policy / Assignment 
{00000000-0000-0000-0000-000000000043} Policy Agent Validate User Policy / Assignment 
{00000000-0000-0000-0000-000000000051} Retrying/Refreshing certificates in AD on MP 
{00000000-0000-0000-0000-000000000061} Peer DP Status reporting 
{00000000-0000-0000-0000-000000000062} Peer DP Pending package check schedule 
{00000000-0000-0000-0000-000000000063} SUM Updates install schedule 
{00000000-0000-0000-0000-000000000071} NAP action 
{00000000-0000-0000-0000-000000000101} Hardware Inventory Collection Cycle 
{00000000-0000-0000-0000-000000000102} Software Inventory Collection Cycle 
{00000000-0000-0000-0000-000000000103} Discovery Data Collection Cycle 
{00000000-0000-0000-0000-000000000104} File Collection Cycle 
{00000000-0000-0000-0000-000000000105} IDMIF Collection Cycle 
{00000000-0000-0000-0000-000000000106} Software Metering Usage Report Cycle 
{00000000-0000-0000-0000-000000000107} Windows Installer Source List Update Cycle 
{00000000-0000-0000-0000-000000000108} Software Updates Assignments Evaluation Cycle 
{00000000-0000-0000-0000-000000000109} Branch Distribution Point Maintenance Task 
{00000000-0000-0000-0000-000000000110} DCM policy 
{00000000-0000-0000-0000-000000000111} Send Unsent State Message 
{00000000-0000-0000-0000-000000000112} State System policy cache cleanout 
{00000000-0000-0000-0000-000000000113} Scan by Update Source 
{00000000-0000-0000-0000-000000000114} Update Store Policy 
{00000000-0000-0000-0000-000000000115} State system policy bulk send high 
{00000000-0000-0000-0000-000000000116} State system policy bulk send low 
{00000000-0000-0000-0000-000000000120} AMT Status Check Policy 
{00000000-0000-0000-0000-000000000121} Application manager policy action 
{00000000-0000-0000-0000-000000000122} Application manager user policy action 
{00000000-0000-0000-0000-000000000123} Application manager global evaluation action 
{00000000-0000-0000-0000-000000000131} Power management start summarizer 
{00000000-0000-0000-0000-000000000221} Endpoint deployment reevaluate 
{00000000-0000-0000-0000-000000000222} Endpoint AM policy reevaluate 
{00000000-0000-0000-0000-000000000223} External event detection 

Powershell Check client actions

# client_actions.ps1: Powershell Check Client Actions
# 
# Reference:
# 
# https://github.com/andrebocchini/sccm-powershell-automation-module/blob/master/SCCM_Client.psm1
#
# Todo:
# http://jrich523.wordpress.com/2011/06/13/creating-a-timer-event-in-powershell/
#
# Software Metering Usage Report Cycle                {00000000-0000-0000-0000-000000000106}
# Request & Evaluate Machine Policy                   {8EF4D77C-8A23-45c8-BEC3-630827704F51}
# Updates Source Scan Cycle                           {00000000-0000-0000-0000-000000000113}
# Request & Evaluate User Policy                      {3A88A2F3-0C39-45fa-8959-81F21BF500CE}
# Hardware Inventory Collection Cycle                 {00000000-0000-0000-0000-000000000101}
# Software Inventory Collection Cycle                 {00000000-0000-0000-0000-000000000102}
# Application Global Evaluation Task                  {00000000-0000-0000-0000-000000000123}
# Software Updates Assignments Evaluation Cycle       {00000000-0000-0000-0000-000000000108}
# Discovery Data Collection Cycle                     {00000000-0000-0000-0000-000000000103}            
# MSI Product Source Update Cycle                     {00000000-0000-0000-0000-000000000107}            
# Standard File Collection Cycle                      {00000000-0000-0000-0000-000000000104} 
#

function fnCheck_Agent_Settings($computer)
{

    $found_list = @()
    $missing_list = @()

    $path = "root\ccm\Policy\Machine\ActualConfig"
    $wmi_object = "CCM_ClientActions"
     
    $data = "WMI Path: " + "\\" + $computer + "\" + $path
    
    Write-Host "Computer: " $computer
    Write-Host ""
    Write-Host $data
    Write-Host "Class   : " $wmi_object

    $actions = Get-WmiObject -Class $wmi_object -Namespace $path -ComputerName $computer

    $count = $actions.Count

    $Software_Metering_Usage_Report_Cycle_flag = $false #
    $Request_and_Evaluate_Machine_Policy_flag = $false
    $Updates_Source_Scan_Cycle_flag = $false
    $Request_and_Evaluate_User_Policy_flag = $false
    $Hardware_Inventory_Collection_Cycle_flag = $false
    $Software_Inventory_Collection_Cycle_flag = $false
    $Application_Global_Evaluation_Task_flag = $false
    $Software_Updates_Assignments_Evaluation_Cycle_flag = $false
    $Discovery_Data_Collection_Cycle_flag = $false
    $MSI_Product_Source_Update_Cycle_flag = $false
    $Standard_File_Collection_Cycle_flag = $false

    foreach ($action in $actions)
    {
       $action_object = New-Object PSObject
       $action_object | Add-Member Name ""
       $action_object | Add-Member ActionID $action.ActionID

       $matched_id = $true

       switch ($action.Name)
       {
        'Software Metering Usage Report Cycle' {$Software_Metering_Usage_Report_Cycle_flag = $true
                                                $action_object.Name = $action.Name }

        'Request & Evaluate Machine Policy' {$Request_and_Evaluate_Machine_Policy_flag = $true
                                             $action_object.Name = "Machine Policy Retrieval & Evaluation Cycle" }

        'Updates Source Scan Cycle' {$Updates_Source_Scan_Cycle_flag = $true
                                     $action_object.Name = "Software Updates Scan Cycle"}

        'Request & Evaluate User Policy' {$Request_and_Evaluate_User_Policy_flag = $true
                                          $action_object.Name = "User Policy Retrieval & Evaluation Cycle"}

        'Hardware Inventory Collection Cycle' {$Hardware_Inventory_Collection_Cycle_flag = $true
                                               $action_object.Name = "Hardware Inventory Cycle"}

        'Software Inventory Collection Cycle' {$Software_Inventory_Collection_Cycle_flag = $true
                                               $action_object.Name = "Software Inventory Cycle"}

        'Application Global Evaluation Task' {$Application_Global_Evaluation_Task_flag = $true
                                              $action_object.Name = "Application Deployment Evualation Cycle"}

        'Software Updates Assignments Evaluation Cycle' {$Software_Updates_Assignments_Evaluation_Cycle_flag = $true
                                                         $action_object.Name = "Software Updates Deployment Evaluation Cycle"}

        'Discovery Data Collection Cycle' {$Discovery_Data_Collection_Cycle_flag = $true
                                            $action_object.Name = "Discovery Data Collection Cycle"}

        'MSI Product Source Update Cycle' {$MSI_Product_Source_Update_Cycle_flag = $true
                                           $action_object.Name = "Windows Installer Source List Update Cycle"}

        'Standard File Collection Cycle' {$Standard_File_Collection_Cycle_flag = $true
                                          $action_object.Name = "File Collection Cycle"}

        default {$matched_id = $false; $action_object.Name = $action.Name}
       }

       # $action_object | Add-Member Matched_Message $matched_id
       $found_list += $action_object
    }

    if (@($found_list).Count -gt 0)
    {
        $found_list = $found_list | Sort-Object Name
    }

    # Software Updates Deployment Evaluation Cycle
    if ($Software_Updates_Assignments_Evaluation_Cycle_flag -eq $false)
    {
        $missing_list += "Software Updates Deployment Evaluation Cycle"
    }

    # Software Metering Usage Report Cycle 
    # Software Metering Usage Report Cycle - Internal
    if ($Software_Metering_Usage_Report_Cycle_flag -eq $false)
    {
        $missing_list += "Software Metering Usage Report Cycle"
    }

    # Machine Policy Retrieval & Evaluation Cycle
    # Request & Evaluate Machine Policy - Internal
    if ($Request_and_Evaluate_Machine_Policy_flag -eq $false)
    {
        $missing_list += "Machine Policy Retrieval & Evaluation Cycle"        
    }

    # Software Updates Scan Cycle
    # Updates Source Scan Cycle - Internal
    if ($Updates_Source_Scan_Cycle_flag -eq $false)
    {
        $missing_list += "Software Updates Scan Cycle"
    }

    # User Policy Retrieval & Evaluation Cycle
    if ($Request_and_Evaluate_User_Policy_flag -eq $false)
    {
        $missing_list += "User Policy Retrieval & Evaluation Cycle"
    }

    # Hardware Inventory Cycle
    if ($Hardware_Inventory_Collection_Cycle_flag -eq $false)
    {
        $missing_list += "Hardware Inventory Cycle"
    }

    # Software Inventory Cycle
    if ($Software_Inventory_Collection_Cycle_flag -eq $false)
    {
        $missing_list += "Software Inventory Cycle"
    }

    # Application Deployment Evualation Cycle
    if ($Application_Global_Evaluation_Task_flag -eq $false)
    {
        $missing_list += "Application Deployment Evualation Cycle"
    }

    # Discovery Data Collection Cycle
    if ($Discovery_Data_Collection_Cycle_flag -eq $false)
    {
        $missing_list += "Discovery Data Collection Cycle"
    }
    
    # Windows Installer Source List Update Cycle
    if ($MSI_Product_Source_Update_Cycle_flag -eq $false)
    {
        $missing_list += "Windows Installer Source List Update Cycle"
    }
    
    # File Collection Cycle
    if ($Standard_File_Collection_Cycle_flag -eq $false)
    {
        $missing_list += "File Collection Cycle"
    }

    return $found_list,$missing_list
}

function fnCheck_Machine($computer)
{
    $data = fnCheck_Agent_Settings "localhost"

    $found_list = $data[0]
    $missing_list = $data[1]
    $actions_ok_flag = $true    

    if ($found_list.Count -gt 0)
    {
        Write-Host ""
        Write-Host "Found Actions ----"
        $found_list | Out-Default
        Write-Host "Found Action Count:" $found_list.Count
    }

    if ($missing_list.Count -gt 0)
    {
        $actions_ok_flag = $false
        Write-Host ""
        Write-Host "Missing Actions ----"
        Write-Host ""
        $missing_list | Out-Default
        Write-Host "Missing Action Count: " $missing_list.Count
    }

    Write-Host ""
    Write-Host "Client OK: " -ForegroundColor Cyan -NoNewline

    if ($actions_ok_flag -eq $false)
    {
        Write-Host "No" -ForegroundColor Red
    }

    if ($actions_ok_flag -eq $true)
    {
        Write-Host "Yes" -ForegroundColor Green
    }

    return $actions_ok_flag
}

clear

try
{
    while ($true)
    {
        $result = fnCheck_Machine("localhost")
        Start-Sleep -Seconds 3
    }
}

finally 
{
    Write-Host "Finished.."
}

Powershell Check Client Actions V2

# ---------------------------------------------------------------------------------
# client_actions2.ps1: Powershell Check Client Actions
# ---------------------------------------------------------------------------------
#
# Reference:
# 
# https://github.com/andrebocchini/sccm-powershell-automation-module/blob/master/SCCM_Client.psm1
#
# Todo:
# http://jrich523.wordpress.com/2011/06/13/creating-a-timer-event-in-powershell/
#
# Software Metering Usage Report Cycle                {00000000-0000-0000-0000-000000000106}
# Request & Evaluate Machine Policy                   {8EF4D77C-8A23-45c8-BEC3-630827704F51}
# Updates Source Scan Cycle                           {00000000-0000-0000-0000-000000000113}
# Request & Evaluate User Policy                      {3A88A2F3-0C39-45fa-8959-81F21BF500CE}
# Hardware Inventory Collection Cycle                 {00000000-0000-0000-0000-000000000101}
# Software Inventory Collection Cycle                 {00000000-0000-0000-0000-000000000102}
# Application Global Evaluation Task                  {00000000-0000-0000-0000-000000000123}
# Software Updates Assignments Evaluation Cycle       {00000000-0000-0000-0000-000000000108}
# Discovery Data Collection Cycle                     {00000000-0000-0000-0000-000000000103}            
# MSI Product Source Update Cycle                     {00000000-0000-0000-0000-000000000107}            
# Standard File Collection Cycle                      {00000000-0000-0000-0000-000000000104} 
#

function fnCheck_Agent_Settings($computer)
{

    $action_list = @()

    $path = "root\ccm\Policy\Machine\ActualConfig"
    $wmi_object = "CCM_ClientActions"
    
    Write-Host "Scanning: " -ForegroundColor Cyan -NoNewline
    Write-Host $computer -ForegroundColor Yellow -NoNewline

    try
    {
        $actions = Get-WmiObject -Class $wmi_object -Namespace $path -ComputerName $computer -ErrorAction Stop
        $wmi_connection_flag = $true
    }
    catch
    {
        $wmi_connection_flag = $false
        $actions = @()
    }

    $Software_Metering_Usage_Report_Cycle_flag = $false #
    $Request_and_Evaluate_Machine_Policy_flag = $false
    $Updates_Source_Scan_Cycle_flag = $false
    $Request_and_Evaluate_User_Policy_flag = $false
    $Hardware_Inventory_Collection_Cycle_flag = $false
    $Software_Inventory_Collection_Cycle_flag = $false
    $Application_Global_Evaluation_Task_flag = $false
    $Software_Updates_Assignments_Evaluation_Cycle_flag = $false
    $Discovery_Data_Collection_Cycle_flag = $false
    $MSI_Product_Source_Update_Cycle_flag = $false
    $Standard_File_Collection_Cycle_flag = $false

    foreach ($action in $actions)
    {
       $action_object = New-Object PSObject
       $action_object | Add-Member Name ""
       $action_object | Add-Member ActionID $action.ActionID
       $action_object | Add-Member Status "Matched"

       $matched_id = $true

       switch ($action.Name)
       {
        'Software Metering Usage Report Cycle' {$Software_Metering_Usage_Report_Cycle_flag = $true
                                                $action_object.Name = $action.Name }

        'Request & Evaluate Machine Policy' {$Request_and_Evaluate_Machine_Policy_flag = $true
                                             $action_object.Name = "Machine Policy Retrieval & Evaluation Cycle" }

        'Updates Source Scan Cycle' {$Updates_Source_Scan_Cycle_flag = $true
                                     $action_object.Name = "Software Updates Scan Cycle"}

        'Request & Evaluate User Policy' {$Request_and_Evaluate_User_Policy_flag = $true
                                          $action_object.Name = "User Policy Retrieval & Evaluation Cycle"}

        'Hardware Inventory Collection Cycle' {$Hardware_Inventory_Collection_Cycle_flag = $true
                                               $action_object.Name = "Hardware Inventory Cycle"}

        'Software Inventory Collection Cycle' {$Software_Inventory_Collection_Cycle_flag = $true
                                               $action_object.Name = "Software Inventory Cycle"}

        'Application Global Evaluation Task' {$Application_Global_Evaluation_Task_flag = $true
                                              $action_object.Name = "Application Deployment Evualation Cycle"}

        'Software Updates Assignments Evaluation Cycle' {$Software_Updates_Assignments_Evaluation_Cycle_flag = $true
                                                         $action_object.Name = "Software Updates Deployment Evaluation Cycle"}

        'Discovery Data Collection Cycle' {$Discovery_Data_Collection_Cycle_flag = $true
                                            $action_object.Name = "Discovery Data Collection Cycle"}

        'MSI Product Source Update Cycle' {$MSI_Product_Source_Update_Cycle_flag = $true
                                           $action_object.Name = "Windows Installer Source List Update Cycle"}

        'Standard File Collection Cycle' {$Standard_File_Collection_Cycle_flag = $true
                                          $action_object.Name = "File Collection Cycle"}

        # default {$action_object.Name = $action.Name ; $action_object.Status = "Unmatched"}
       }

       # $action_object | Add-Member Matched_Message $matched_id
       $action_list += $action_object
    }

    # Software Updates Deployment Evaluation Cycle
    if ($Software_Updates_Assignments_Evaluation_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Software Updates Deployment Evaluation Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object
    }

    # Software Metering Usage Report Cycle 
    # Software Metering Usage Report Cycle - Internal
    if ($Software_Metering_Usage_Report_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Software Metering Usage Report Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object

    }

    # Machine Policy Retrieval & Evaluation Cycle
    # Request & Evaluate Machine Policy - Internal
    if ($Request_and_Evaluate_Machine_Policy_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Machine Policy Retrieval & Evaluation Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # Software Updates Scan Cycle
    # Updates Source Scan Cycle - Internal
    if ($Updates_Source_Scan_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Software Updates Scan Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # User Policy Retrieval & Evaluation Cycle
    if ($Request_and_Evaluate_User_Policy_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "User Policy Retrieval & Evaluation Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # Hardware Inventory Cycle
    if ($Hardware_Inventory_Collection_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Hardware Inventory Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # Software Inventory Cycle
    if ($Software_Inventory_Collection_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Software Inventory Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # Application Deployment Evualation Cycle
    if ($Application_Global_Evaluation_Task_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Application Deployment Evaluation Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    # Discovery Data Collection Cycle
    if ($Discovery_Data_Collection_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Discovery Data Collection Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }
    
    # Windows Installer Source List Update Cycle
    if ($MSI_Product_Source_Update_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "Windows Installer Source List Update Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }
    
    # File Collection Cycle
    if ($Standard_File_Collection_Cycle_flag -eq $false)
    {
        $action_object = New-Object PSObject
        $action_object | Add-Member Name "File Collection Cycle"
        $action_object | Add-Member ActionID ""
        $action_object | Add-Member Status "Missing"
        $action_list += $action_object       
    }

    $missing_items = @($action_list | Where-Object {$_.Status -eq "Missing"}).Count
    $matched_items = @($action_list | Where-Object {$_.Status -eq "Matched"}).Count

    if ($wmi_connection_flag -eq $false)
    {
        $computer_status = "Can't Connect"
    }

    if ($wmi_connection_flag -eq $true)
    {
        $computer_status = "OK"

        if ($missing_items -gt 0)
        {
            $computer_status = "Not OK"
        }
    }

    $action_list = $action_list | Sort-Object Name

    $computer_object = New-Object PSObject
    $computer_object | Add-Member Computer $computer
    $computer_object | Add-Member Status $computer_status
    $computer_object | Add-Member Actions $action_list
    $computer_object | Add-Member Matched_Count $matched_items
    $computer_object | Add-Member Missing_Count $missing_items

    if ($computer_object.Status -eq "OK")
    {
        Write-Host " - OK" -ForegroundColor Green
    }

    if ($computer_object.Status -eq "Not OK")
    {
        Write-Host " - Not OK" -ForegroundColor Green
    }

    if ($computer_object.Status -eq "Can't Connect")
    {
        Write-Host " - Can't Connect" -ForegroundColor Magenta
    }

    return $computer_object
}

function fnReport_Results($results)
{
    $bad_results = $results | Where-Object {$_.Status -eq "Not OK"}
    $good_results = $results | Where-Object {$_.Status -eq "OK"}

    $missing_action_count = @($bad_results).Count

    Write-Host ""
    Write-Host "Machines with Full Actions   : " -NoNewline
    Write-Host  @($good_results).Count -ForegroundColor Green

    if ($missing_action_count -eq 0) { return }
    Write-Host "Machines with Missing Actions: " -NoNewLine
    write-Host $missing_action_count -ForegroundColor Red
    Write-Host ""

    foreach ($bad_result in $bad_results)
    {
        $found_action_count = @($bad_result.Actions | Where-Object {$_.Status -eq "Matched"}).Count

        Write-Host "Computer     : " $bad_result.Computer
        Write-Host "Matched Count: " $bad_result.Matched_Count
        Write-Host "Missing Count: " $bad_result.Missing_Count
        Write-Host ""
        
        if ($found_action_count -gt 0)
        {
            Write-Host "Found Actions:"
            Write-Host ""
            $bad_result.Actions | Where-Object {$_.Status -eq "Matched"} | Select-Object Name,ActionID
            Write-Host ""
        }

        Write-Host "Missing Actions:"
        Write-Host ""
        $bad_result.Actions | Where-Object {$_.Status -eq "Missing"} | Select-Object Name
        Write-Host ""
        Write-Host "-----------------------------------------------------------------------------------------"
        Write-Host ""
    }

}

# --------------------------- MAINLINE ------------------------------------

clear
Write-Host "Scanning Actions on SCCM Clients..."
Write-Host ""

$computer_list = @("localhost","localhost")

try
{
    while ($true)
    {
        $results = @()

        foreach ($computer in $computer_list)
        {
            $computer_result = fnCheck_Agent_Settings $computer
            $results += $computer_result
        }

        fnReport_Results $results
        Start-Sleep -Seconds 5
        Write-Host ""
    }

}

finally
{
    Write-Host ""
    Write-Host "Finished"
}

Powershell Monitor Client Actions

# ----------------------------------------------------------------
# sccm_monitor.ps1
# ----------------------------------------------------------------

function Get-ScriptDirectory
{
  $Invocation = (Get-Variable MyInvocation -Scope 1).Value
  Split-Path $Invocation.MyCommand.Path
}

clear
$global:computer = "localhost"

$valid_computer = $false

$global:event_list = @()

while ($valid_computer -eq $false)
{
    try
    {
        $os = Get-WmiObject "Win32_OperatingSystem" -ComputerName $computer -ErrorAction SilentlyContinue
        $global:install_date = [System.Management.ManagementDateTimeConverter]::ToDateTime($os.InstallDate)
        $global:osd_finish = [System.Management.ManagementDateTimeConverter]::ToDateTime($os.LastBootUpTime)
        $valid_computer = $true
    }

    catch
    {
        Write-Host "Waiting for machine $computer ..."
        Write-Host ""
        Start-Sleep -Seconds 10
        $valid_computer = $false
    }
}

$wmi_path = "root\ccm\Policy\Machine\ActualConfig"
$class = "CCM_ClientActions"

$query_create = "select * from __InstanceCreationEvent within 3 where targetinstance isa '$class'"
$query_delete = "select * from __InstanceDeletionEvent within 3 where targetinstance isa '$class'"
$query_modification = "select * from __InstanceModificationEvent within 3 where targetinstance isa '$class'"
$global:start_time = Get-Date

$action_create = 
{ 
    Write-Host "Event     : Create Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""

    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Create"
    $global:event_list += $event_object
}

$action_delete = 
{ 
    Write-Host "Event     : Delete Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""

    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Delete"
    $global:event_list += $event_object
}

$action_modification = 
{ 
    Write-Host "Event     : Modification Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""
    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Modify"
    $global:event_list += $event_object
}

register-wmiEvent -query $query_create -sourceIdentifier "sccm_create" -messageData "SCCM_Create" -Namespace $wmi_path -ComputerName $computer -Action $action_create | Out-Null
register-wmiEvent -query $query_delete -sourceIdentifier "sccm_delete" -messageData "SCCM_Delete" -Namespace $wmi_path -ComputerName $computer -Action $action_delete | Out-Null
register-wmiEvent -query $query_modification -sourceIdentifier "sccm_modification" -messageData "SCCM_Mod" -Namespace $wmi_path -ComputerName $computer -Action $action_modification | Out-Null

clear

Write-Host "Waiting for SCCM client action events on:" $computer
Write-Host ""

try
{
    while ($true) 
    {    
        Start-Sleep -Seconds 1 
    }
}

finally
{

    Unregister-Event "sccm_create"
    Unregister-Event "sccm_delete"
    Unregister-Event "sccm_modification"

    if ($global:event_list.Count -gt 0)
    {
        Write-Host "Total Events: " $global:event_list.Count

        Write-Host ""

        $script_path = Get-ScriptDirectory

        $file_name_csv = $script_path + "\" + $computer + "_events.csv"
        $file_name_txt = $script_path + "\" + $computer + "_events.txt"

        Write-Host "Writing Events to : " $file_name_csv
        $event_list | Export-Csv -NoTypeInformation $file_name_csv -Force
        Write-Host "Writing Events to : " $file_name_txt
        $event_list | ft -AutoSize | Out-File $file_name_txt -Force -Width 130
    }

    Write-Host "Finished..."
}

Powershell Monitor Client Actions

# ----------------------------------------------------------------
# sccm_monitor.ps1
# ----------------------------------------------------------------

function Get-ScriptDirectory
{
  $Invocation = (Get-Variable MyInvocation -Scope 1).Value
  Split-Path $Invocation.MyCommand.Path
}

clear
$global:computer = "localhost"

$valid_computer = $false

$global:event_list = @()

while ($valid_computer -eq $false)
{
    try
    {
        $os = Get-WmiObject "Win32_OperatingSystem" -ComputerName $computer -ErrorAction SilentlyContinue
        $global:install_date = [System.Management.ManagementDateTimeConverter]::ToDateTime($os.InstallDate)
        $global:osd_finish = [System.Management.ManagementDateTimeConverter]::ToDateTime($os.LastBootUpTime)
        $valid_computer = $true
    }

    catch
    {
        Write-Host "Waiting for machine $computer ..."
        Write-Host ""
        Start-Sleep -Seconds 10
        $valid_computer = $false
    }
}

$wmi_path = "root\ccm\Policy\Machine\ActualConfig"
$class = "CCM_ClientActions"

$query_create = "select * from __InstanceCreationEvent within 3 where targetinstance isa '$class'"
$query_delete = "select * from __InstanceDeletionEvent within 3 where targetinstance isa '$class'"
$query_modification = "select * from __InstanceModificationEvent within 3 where targetinstance isa '$class'"
$global:start_time = Get-Date

$action_create = 
{ 
    Write-Host "Event     : Create Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""

    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Create"
    $global:event_list += $event_object
}

$action_delete = 
{ 
    Write-Host "Event     : Delete Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""

    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Delete"
    $global:event_list += $event_object
}

$action_modification = 
{ 
    Write-Host "Event     : Modification Event"
    Write-Host "Computer  :" $Event.SourceEventArgs.NewEvent.PSComputerName
    write-host "Start Time:" $start_time
    Write-Host "OSD Finish:" $osd_finish
    $e = $Event.SourceEventArgs.NewEvent 
    Write-Host "Event Time:" $Event.TimeGenerated 
    Write-Host "Name      :" $e.TargetInstance.Name 
    Write-Host "ActionID  :" $e.TargetInstance.ActionID
    Write-Host ""
    $event_object = New-Object PSObject
    $event_object | Add-Member Computer $Event.SourceEventArgs.NewEvent.PSComputerName
    $event_object | Add-Member Event_Time $Event.TimeGenerated
    $event_object | Add-Member Name $e.TargetInstance.Name
    $event_object | Add-Member ActionID $e.TargetInstance.ActionID
    $event_object | Add-Member Event_Type "Modify"
    $global:event_list += $event_object
}

register-wmiEvent -query $query_create -sourceIdentifier "sccm_create" -messageData "SCCM_Create" -Namespace $wmi_path -ComputerName $computer -Action $action_create | Out-Null
register-wmiEvent -query $query_delete -sourceIdentifier "sccm_delete" -messageData "SCCM_Delete" -Namespace $wmi_path -ComputerName $computer -Action $action_delete | Out-Null
register-wmiEvent -query $query_modification -sourceIdentifier "sccm_modification" -messageData "SCCM_Mod" -Namespace $wmi_path -ComputerName $computer -Action $action_modification | Out-Null

clear

Write-Host "Waiting for SCCM client action events on:" $computer
Write-Host ""

try
{
    while ($true) 
    {    
        Start-Sleep -Seconds 1 
    }
}

finally
{

    Unregister-Event "sccm_create"
    Unregister-Event "sccm_delete"
    Unregister-Event "sccm_modification"

    if ($global:event_list.Count -gt 0)
    {
        Write-Host "Total Events: " $global:event_list.Count

        Write-Host ""

        $script_path = Get-ScriptDirectory

        $file_name_csv = $script_path + "\" + $computer + "_events.csv"
        $file_name_txt = $script_path + "\" + $computer + "_events.txt"

        Write-Host "Writing Events to : " $file_name_csv
        $event_list | Export-Csv -NoTypeInformation $file_name_csv -Force
        Write-Host "Writing Events to : " $file_name_txt
        $event_list | ft -AutoSize | Out-File $file_name_txt -Force -Width 130
    }

    Write-Host "Finished..."
}

SCCM Verbose Logging

SCEP

SCCM 2012 Triggers

Install SCEP

"C:\Windows\ccmsetup\SCEPInstall.exe" /q /s

Logs

•%allusersprofile%\Microsoft\Microsoft Antimalware\Support contains the SCEP client operational logs, which include:

C:\Users\All Users\Microsoft\Microsoft Antimalware
C:\Users\All Users\Microsoft\Microsoft Security Client\Support

•MPDetection-XXXXXXXX-XXXXXX.log that logs information pertaining to malware detections
•MPLog-XXXXXXXX-XXXXXX.log that logs all of the SCEP clients activity to include definition updates, malware detections, and the raising of behavior monitoring alerts

•%allusersprofile%\Microsoft\Microsoft Security Client\Support contains the SCEP client installation logs, which include:
•EppSetup.log
•MSSecurityClient_Setup_epp_install.log
•MSSecurityClient_Setup_epp_install.log
•MSSecurityClient_Setup_mp_ambits_install.log


c:\Windows\ccm\logs\EndpointProtectionAgent.log C:\ProgramData\Microsoft\Microsoft Antimalware\Support\MPLog-*.log


Endpoint deployment reevaluate
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000221}" /NOINTERACTIVE 

Endpoint AM policy reevaluate
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000222}" /NOINTERACTIVE 

Software Updates
WMIC /namespace:\\root\ccm path sms_client CALL TriggerSchedule "{00000000-0000-0000-0000-000000000108}" /NOINTERACTIVE 

# Powershell Version

$strComputer = ""
$SMSCli = [wmiclass] "\\$strComputer\root\ccm:SMS_Client"
$SMSCli.TriggerSchedule("{00000000-0000-0000-0000-000000000001}")

Management Point Info

Get a list of all the management points
http://<ServerName>/sms_mp/.sms_aut?mplist

SCCM 2012 Powershell Module

# Use SCCM Configuration Manage Module - x86 Powershell Only

Import-Module "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1"
Set-Location XXX:

Get-Command -Module ConfigurationManager

Unlock Object

PXE

UEFI

Windows PE Confirmation

1. Boot into Windows PE.
1. Open a command prompt at boot.
2. In the command prompt at boot, type the command below and press Enter. (see screenshot below)

wpeutil UpdateBootInfo

3. In the command prompt at boot, type the command below and press Enter.

reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType

4. This command returns 0x1 if the PC boots in Legacy BIOS mode, or 0x2 if the PC boots in UEFI mode.

0x1 - Legacy
0x2 - UEFI

Virtual Labs

Diskpart Commands

INACTIVATE - Mark the selected partition and "Inactive"
ACTIVE - Mark the selected partition as "Active"

OSD General Information

OSD

DISKPART> select disk 1

Disk 1 is now the selected disk.

DISKPART> detail disk

Verbatim USB Device
Disk ID: C3072E18
Type   : USB
Status : Online
Path   : 0
Target : 0
LUN ID : 0
Location Path : UNAVAILABLE
Current Read-only State : No
Read-only  : No
Boot Disk  : No
Pagefile Disk  : No
Hibernation File Disk  : No
Crashdump Disk  : No
Clustered Disk  : No

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
  Volume 3     E   SMSBOOT      FAT32  Removable     14 GB  Healthy

-----

DISKPART> select partition 1

Partition 1 is now the selected partition.

DISKPART> detail partition

Partition 1
Type  : 0C
Hidden: No
Active: Yes
Offset in Bytes: 1646592

  Volume ###  Ltr  Label        Fs     Type        Size     Status     Info
  ----------  ---  -----------  -----  ----------  -------  ---------  --------
* Volume 3     E   SMSBOOT      FAT32  Removable     14 GB  Healthy

-------

clean
create partition primary
select partition 1
active
format fs=fat32 quick label="SMSBOOT"

Troubleshooting

Documentation

Powershell 3 Issue - SCCM 2012 ?

http://blogs.technet.com/b/configmgrteam/archive/2012/12/18/known-issue-configuration-manager-management-points-collocated-with-clients-fail.aspx
http://support.microsoft.com/kb/2796086

SCCM Downloads needed

SCCM 2012 Training

SCCM 2012 Installation

Powershell Pre-Req Install
Import-module servermanager
Add-WindowsFeature Web-Common-Http,Web-Static-Content,Web-Default-Doc,Web-Dir-Browsing,Web-Http-Errors,Web-Http-Redirect,Web-Asp-Net,Web-Net-Ext,Web-ASP,Web-ISAPI-Ext,Web-ISAPI-Filter,Web-Http-Logging,Web-Log-Libraries,Web-Request-Monitor,Web-Http-Tracing,Web-Basic-Auth,Web-Windows-Auth,Web-Url-Auth,Web-Filtering,Web-IP-Security,Web-Stat-Compression,Web-Mgmt-Tools,Web-WMI,NET-Framework,RDC,BITS,powershell-ise -Restart

Need:

Microsoft Report Viewer Redistributable 2008
http://www.microsoft.com/en-au/download/details.aspx?id=6576
ReportViewer.exe

Windows Server Update Services 3.0 SP2
http://www.microsoft.com/en-us/download/details.aspx?id=5216
WSUS30-KB972455-x64.exe

WSUS Updates

Windows Assessment and Deployment Kit (ADK) for Windows® 8
http://www.microsoft.com/en-au/download/details.aspx?id=30652

From Assessment and Deployment Kit:

- Deployment Tools
- The Windows Preinstallation Environment (Windows PE)
- User State Migration Tool (USMT)

Microsoft Deployment Toolkit (MDT) 2012 Update 1
http://www.microsoft.com/en-au/download/details.aspx?id=25175

SCCM 2012 DP

Install

Import-module servermanager
Add-WindowsFeature Web-ISAPI-Ext,Web-Windows-Auth,Web-Metabase,Web-WMI,Web-Http-Redirect,Web-Scripting-Tools,NET-Framework,RDC,BITS,powershell-ise -Restart

Cleanup (Remove)

Import-Module servermanager
Remove-WindowsFeature Web-WebServer,BITS,RDC -Restart
Remove-WindowsFeature Web-Server,AS-WAS-Support,AS-TCP-Activation,AS-Named-Pipes,NET-Framework,WAS,powershell-ise -Restart

Notes client.acu in hman.box folder.

Force DP Package Replication

New-Item D:\Apps\SCCM\inboxes\hman.box\client.acu -type file

SetSPN

To Set SPN

setspn –A MSSQLSvc/S12LEVEL1:1433 SCCM\SQLService
setspn –A MSSQLSvc/S12LEVEL1.sccm.local:1433 SCCM\SQLService

To Verify a SPN

setspn –L SCCM\SQLService

SCCM 2012 Content Management

SCCM 2012 Client

Patching

Downloads

PreRreq Checker

R:\SMSSETUP\BIN\X64>prereqchk.exe /PRI /SQL <server> /SDK <server>

SQL Colation Settings

SQL_Latin1_General_CP1_CI_AS

Videos

Powershell

Get .NET Version

gci 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' | sort pschildname -des | foreach-object {$_.name; $_.GetValue("Version");}

Search Log files for errors (summary)

$path = "c:\sccm\logs\*.*"
$search_string = "error"
Get-ChildItem $path | Select-String $search_string | select-object Path | Group-Object Path | Select-Object Name

Fix Issue with DP Availability

Error in sitestat.log:

omGetServerRoleAvailabilityState could not read from the registry on S12LEVEL1.sccm.local; error = 6: SMS_SITE_SYSTEM_STATUS_SUMMARIZER
--->: Failed to get the Availability State on server S12LEVEL1.sccm.local for role SMS Distribution Point. SMS_SITE_SYSTEM_STATUS_SUMMARIZER

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\SMS\Operations Management\SMS Server Role\SMS Distribution Point" -Name "Availability State" -Value 0 -Type DWord

Client Push

Powershell (SCCM 2012 cmdlets)

import-module D:\Apps\SCCM\AdminConsole\bin\ConfigurationManager.psd1

# ----------------------------------------------------------------------------------------
# fnConvert_WMI_Time
# ----------------------------------------------------------------------------------------

function fnConvert_WMI_Time($value)
{
    $value = "20130221" + $value.Substring(8)
    $time = [System.Management.ManagementDateTimeconverter]::ToDateTime($value)    
    $formatted_time = "{0:hh:mm:ss tt}" -f $time
    return $formatted_time
}

# ----------------------------------------------------------------------------------------
# fnConvert_Days
# ----------------------------------------------------------------------------------------

function fnConvert_Days($value)
{
    $day = ""

    if (($value -band 1) -eq 1)
    {
        $day += "Sunday,"
    }

    if (($value -band 2) -eq 2)
    {
        $day += "Monday,"
    }

    if (($value -band 4) -eq 4)
    {
        $day += "Tuesday,"
    }

    if (($value -band 8) -eq 8)
    {
        $day += "Wednesday,"
    }

    if (($value -band 16) -eq 16)
    {
        $day += "Thursday,"
    }

    if (($value -band 32) -eq 32)
    {
        $day += "Friday,"
    }

    if (($value -band 64) -eq 64)
    {
        $day += "Saturday,"
    }

    if ($day.Length -gt 0)
    {
        $day = [string]$day.Substring(0,$day.Length-1)
    }

    return $day
}

# ----------------------------------------------------------------------------------------
# fnGet_Task_Details
# ----------------------------------------------------------------------------------------

function fnGet_Task_Details
{   

    $provider = $null

    try
    {
      $provider = Get-WmiObject -Namespace root\sms -Class SMS_ProviderLocation -Filter 'ProviderForLocalSite=True' -ErrorAction SilentlyContinue
    }

    catch
    {
    }

    if ($provider -eq $null)
    {
        return
    }

    $machine = $provider.Machine
    $wmi_path = $provider.NamespacePath.Substring($provider.NamespacePath.IndexOf("root"))
    $sitecode = $wmi_path.Substring(14)

	$task_list = Get-WmiObject -namespace $wmi_path -ComputerName $machine -query ("Select * From SMS_SCI_SQLTask where SiteCode = '" + $SiteCode + "'  and FileType=2")
    Invoke-WmiMethod -Path SMS_SiteControlFile -Name RefreshSCF -ArgumentList $sitecode -Computername $machine -Namespace "root\SMS\site_$sitecode" | Out-Null
        
    foreach ($task in $task_list)
	{
        $task_name = $task.ItemName        
        $device_name = ""

        if ($task.Enabled -eq $true)
        {            
            $task_enabled = $task.Enabled
            $start_after = fnConvert_WMI_Time ($task.BeginTime)
            $last_start_time = fnConvert_WMI_Time ($task.LatestBeginTime)
            $days = fnConvert_Days $task.DaysOfWeek
            $device_name = $task.DeviceName

            write-Host ""
			write-host "Task Name       : $task_name"
            Write-Host "Task Enabled    : $task_enabled"
            Write-Host ""
            Write-Host "Days            : $days"
            Write-Host "Start After     : $start_after"
            write-Host "Last Start Time : $last_start_time"
            Write-Host "Backup Path     : $device_name"
            Write-Host ""

        }
     }
}

clear
fnGet_Task_Details

Documentation References

SCEP / FEP

XP

Machine Restart

To Check when a machine resstart look for System Event ID: 6009

Get-EventLog "System" | Where-Object {$_.EventID -eq 6009} | Select-Object TimeGenerated
$server = "SERVER1"
Get-EventLog "System" -ComputerName $server | Where-Object {$_.EventID -eq 6009} |  Select-Object TimeGenerated, @{Name="Day";Expression={$_.TimeGenerated.DayOfWeek}} | format-table -Auto

SCCM 2012 OSD

' Hides current Progress UI to bring the HTA to the front
 Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")
 ProgressUI.CloseProgressDialog
 ' Create a WshShell object
 set sh = CreateObject("Wscript.Shell")
 ' Call the Run method, and pass your command to it (eg. "mshta.exe MyHTA.hta").
 ' The last parameter ensures that the VBscript does not proceed / terminate until the mshta process is closed.
 call sh.Run("select.hta", 1, True)

SCCM 2012 SQL Views

select * from v_CurrentAdvertisementAssignments
select * from v_AppDeploymentSummary
select * from v_ApplicationAssignment
select * from SMSPackages_All

Application Management Views in Configuration Manager
http://technet.microsoft.com/en-us/library/dn581963.aspx

How to make a Prestage USB on SCCM 2012

This involves installed the Windows 8 AIK first.


Make WinPE 4.0 --> 6.2.9200 (Windows 8) 

1.   Goto Tools prompt:

Run "Deployment and Imaging Tools Environment" with UAC" under Windows kits "Windows ADK"

2. Create PE directory on local machine:
copype amd64 C:\WinPE_amd64

3. Make USB Key - Windows PE (G: Drive below is the drive letter of the USB):

MakeWinPEMedia /UFD c:\WinPE_amd64 G:

4. Create Prestage Media via SCCM Console:

Export WIM file to "C:\Prestage_Final\v6.5.0_Prestage.wim

5. Split the file to prepare to copy to USB:

dism /split-image /imagefile:C:\Prestage_Final\Prestage_12.1_Final.wim /SWMFile:C:\Prestage_Final\Prestage_12.1_Final_Split.wim /FileSize:2000
dism /split-image /imagefile:C:\Prestage_Final\v12.1_Prestage.wim /SWMFile:C:\Prestage_Final\v12.1_Prestage_Split.wim /FileSize:2000

6. Make a Deploy folder USB (G:\)

Create a folder on the USB

7. Save the following as a file on the USB key: (G:\Deploy\diskpart.txt)

sel disk 0
clean
create partition primary size=500
active
Format FS=NTFS QUICK LABEL="BDEDrive"
Assign letter=s
create partition primary
Format FS=NTFS QUICK LABEL="SYSTEM"
Assign letter=c
rescan

7. Save the following as a file on the USB key: (G:\Deploy\load.cmd)

diskpart /s diskpart.txt
DISM.exe /Apply-Image /ImageFile:v12.1_Prestage_Split.wim /SWMFile:v12.1_Prestage_Split*.wim /ApplyDir:C:\ /Index:1
bcdboot.exe c:\Windows /s S: /f BIOS
del s:\boot\bcd /f /q
copy c:\boot\bcd s:\boot /y
BCDEdit.exe /Store S:\Boot\BCD /Set {ramdiskoptions} ramdisksdidevice partition=C: 
BCDEdit.exe /Store S:\Boot\BCD /Set {Default} device ramdisk=[C:]\sources\boot.wim,{ramdiskoptions} 
BCDEdit.exe /Store S:\Boot\BCD /Set {Default} osdevice ramdisk=[C:]\sources\boot.wim,{ramdiskoptions}
BCDEdit.exe /Store S:\Boot\BCD -set {bootmgr} device partition=S:

8. Transfer the following files to the G:\Deploy directory:

v12.1_Prestage_Split.wim
v12.1_Prestage_Split2.wim
v12.1_Prestage_Split3.wim
v12.1_Prestage_Split4.wim
v12.1_Prestage_Split5.wim
v12.1_Prestage_Split6.wim

Site Changes

Site Navigation

Personal tools