With SCCM CB 1612 technical preview comes the RESTful OData API

Tags

, ,

Read about it here: https://docs.microsoft.com/da-dk/sccm/core/get-started/capabilities-in-technical-preview-1612

As Microsoft writes – “Data that is currently available in the Configuration Manager WMI Provider is now also accessible with the new OData RESTful endpoint” – This is not completely true yet,  but it is a start.

http://cm01/CMRestProvider/Query does not work. It returns error 500 or the result of the previous successful REST call

Running this little piece of PowerShell below, returns the entire list of data that can be extracted. There is a lot!

You can see the entire list in the attached document or make your own.

Not all classes listed are working yet! I hope this will be solved when the feature is released.

$cred = Get-Credential

$url = “http:///CMRestProvider/”

$RESTdata = Invoke-RestMethod -Uri $url -Credential $cred

$RESTdata.value | select name

The entire list: CM-RESTAPI

There are two new logfiles related to REST API, they can be fond at  \Microsoft Configuration Manager\CMProviderLog.

The CMRestProviderService.log shows the history of the REST calls made:

Processing request: http:///CMRestProvider/DeploymentInfo SCCMGraph 26-03-2017 19:17:57 8 (0x0008)
Success: returned 1219 bytes of data SCCMGraph 26-03-2017 19:17:58 8 (0x0008)

REST_LOGfiles

I will come back with more info on this topic later on

Advertisements

Agent fail to download policies

Tags

Agent fails to download it’s policies and there is no errors on management point and the ClientIDManagerStartup.log shows [RegTask] – Client is already registered. Exiting.

Uninstall of the agent (ccmsetup.exe /uninstall) and reinstalling do not help at all.
The issue is that the uninstall do not clean up in ROOT\CCM in WMI

Run this line in a admin powershell prompt:
Get-WMIObject -namespace “root” -query “SELECT * FROM __Namespace where name = ‘ccm’” | remove-wmiobject

Then run the agent installation and grab a cup of coffe, and the agent will installed and are able to download it’s policies
After a few SCCM minutes it will be active and have the “green” icon in the console

/regards

Configmgr – list applications in tasksequence

Ever needed to list all applications in a Tasksequence via powershell?

Function TaskSequenceReferences(){

$AllTS = Get-CMTaskSequence | select Name, sequence

Foreach($TSName in $AllTS.name){
$TS = Get-CMTaskSequence -Name “$TSName” | select Sequence

$TSxml = ConvertTo-Xml $TS#.Sequence
[xml]$XML = $TSxml.OuterXml.Replace(‘&gt;’,’>’).Replace(‘&lt;’,'<‘)

#Application info
$AppList = ($XML.SelectNodes(“//defaultVarList/variable”) | Where-Object {$_.property -like “AppInfo*DisplayName”}).’#text’

Foreach($Appl in $AppList){
Write-Host $Tsname”,”$Appl
}
}

}

 

Configmgr unattended install – SetupWpf.exe. return value 1

Tags

, ,

If you for some reason get this error during unattended installation of Configmgr.

The error is in the C:\ConfigmgrSetup.log

“Failed to create process of SetupWpf.exe. return value 1”

Rename HKLM\Software\Microsoft\SMS to HKLM\Software\Microsoft\SMS_old and try again.

The error occur if the installation has been started and fails. In my case it was due to a SQL issue.

Ccmsetup.log – configmgr2012ac-sp2r2sp1-kb3100144-x64.msp installation failed

Tags

, , ,

Looks like there is a bug in KB3100144 (Description of Cumulative Update 2 for System Center 2012 Configuration Manager Service Pack 2 and System Center 2012 R2 Configuration Manager Service Pack 1). The error occur when you install a management point.
ccmsetup.log:
MSI: There is not enough available disk space on to complete this operation. Installation requires at least 90MB free disk space. File C:\Windows\ccmsetup\configmgr2012acsp2r2sp1kb3074857x64.msp installation failed. Error text: ExitCode: 1603 Action: CcmCheckFreeDiskSpace.

ccmsetup.error

MPsetup.log:
<12/02/15 17:52:05> Installing pre-req using command line “D:\SMS\client\ccmsetup.exe” /UpgradeWithServer:mp
<12/02/15 17:52:22> Pre-req installer “D:\SMS\client\ccmsetup.exe” /UpgradeWithServer:mp finished with exit code 1
<12/02/15 17:52:22> Failed to Install Pre Req CcmSetup. Return Code is 1
<12/02/15 17:52:22> This was a required Pre Req, can not continue.
<12/02/15 17:52:22> Installation Failed. Error Code: 1

Solution:

  1. Uninstall the management point, monitor mpsetup.log till the uninstall is succeded

  2. Uninstall the agent using the switch /uninstall, monitor ccmsetup.log till the uninstall is succeded

  3. Reinstall the agent, but this time include the patch in the installation. C:\windows\ccmsetup\ccmsetup.exe patch=\\<Server>\sms_XXX\hotfix\KB3100144\Client\x64\configmgr2012ac-sp2r2sp1-kb3100144-x64.msp SMSSITECODE=XXX

    XXX = your sitecode
    <Server> = your site server

  4. Install the management point, and you’re done.

 

 

UEFI and WDSNBP pxeboot in the same DHCP scope

Tags

, , ,

** Update 2 **

This is not going to work, I’m able to configure DHCP 2008 with the correct vendor class options and I can see in a trace that the client reads the correct values for option 66 & 67.

But the pxe client do not use the vendor class definitions.

** Update**

After some more testing, it looks like the vendor class require more input, before the client can detect the vendor class.
It is not enough with PXEClient:Arch:00007, it should be like this:
PXEClient:Arch:00007:UNDI:003016

003016 comes from a Vmware client with a E1000 netcard.
A VMxnet3 netcard returns: 003012

A network trace at the DHCP server will show the class a client i using:
VendorClassIdentifier: PXEClient:Arch:00007:UNDI:003016 – Type 60

I tried with a wildcard like: PXEClient:Arch:00007:UNDI:*
Not working 😦

So afterall it might be a problem using vendor class for controlling UEFi pxeboot at a 2008 DHCP….

I will do more testing and update, when there is news – good or bad.

**

 

BranchCache Bob, has an exellent video showing how to configure UEFI and WDSNBP support within the same DHCP scope. https://www.youtube.com/watch?v=k5E97ndlRog. This requires your DHCP to be Windows server 2012! The process at Windows server 2008 DHCP is a bit different.

The script below creates the Vendor Class’ and predefined options at the 2008 DHCP. the newly defined scope option has to be added after the script is executed.

dhcp

::Script start

::UEFI Configuration

::Define vendor Class

netsh dhcp server add class “PXEClient (UEFI x64)” “UEFI PXE Vendor Class” “PXEClient:Arch:00007”

::Define Predefined options

netsh dhcp server add optiondef 67 “UEFI Boot file” STRING 0 Vendor=”PXEClient (UEFI x64)” “SMSBoot\x64\wdsmgfw.efi”

netsh dhcp server add optiondef 60 “UEFI PXEClient” STRING 0 Vendor=”PXEClient (UEFI x64)” “PXEClient”

::Bios Configuration

::Define vendor Class

netsh dhcp server add class “PXEClient (BIOS)” “BIOS PXE Vendor Class” “PXEClient:Arch:00000” 1

::Define Predefined options

netsh dhcp server add optiondef 67 “BIOS Boot file” STRING 0 Vendor=”PXEClient (BIOS)” “SMSBoot\x64\wdsnbp.com”

SCCM 2012 – Delete software update template

Tags

, , , ,

A way to delete Software Update templates from SCCM

List all SUP templates:

$computer = $env:COMPUTERNAME
$namespace = “ROOT\SMS\site_ps1”
$classname = “SMS_Template”
$SiteServer = “Siteserver”

$SoftwareUpdateTemplate = Get-WmiObject -Namespace $NameSpace -Query “Select * from SMS_Template where type = 0” -ComputerName $SiteServer
$SoftwareUpdateTemplate.name

note:

type 0 = Software Update template

Type 1 = Automatic Deployment Rules template

Delete the SUP template named “Templatename”

$computer = $env:COMPUTERNAME
$namespace = “ROOT\SMS\site_ps1”
$classname = “SMS_Template”

$SiteServer = “Siteserver”
$SUPTemplateName = “templatename”

$SoftwareUpdateTemplate = Get-WmiObject -Namespace $NameSpace -Query “Select * from SMS_Template where Name =’$SUPTemplateName'” -ComputerName $SiteServer -ErrorAction STOP

$SoftwareUpdateTemplate.Delete()

Powershell get installed ConfigMgr hotfixes and CU’s

Tags

, , ,

When you look in the Control panel | add/remove programs | view installed updates all Configmgr updates are listed, but the GET-HOTFIX do not return ConfigMgr hotfixes.

ConfigMgr_installed_updates

The script below get the information from registry and return the KB’s installed

It is only tested on Configmgr 2012

#Script start

$ConfigMgrHotfixInfo = Get-ChildItem -Path HKLM:\SOFTWARE\Microsoft\UPDATES -Recurse
$result = $ConfigMgrHotfixInfo | Select-String -Pattern “KB\d{1,7}” -AllMatches | ForEach { $_.Matches } | ForEach { $_.Value }

#Script end

Hotfix_result

SCCM 2007/2012, monitor if the pxeboot certificate expires and write status to the eventlog

This script will get the ValidUntil date from wmi, for the pxeboot certificate that are NOT blocked.

if ValidUntil is less  than 60 days from “today” and write an event in the eventlog (application log) This event can be monitored with SCOM.

I intend to create a scehduled task at all our pxeboot servers, and let the script run weekly.

Eventlog example Valid pxecertificate:

ValidPxeCert

Eventlog example  InValid pxecertificate:

InValidPxeCert

#Script start

$sitecode = new-object -comobject “Microsoft.SMS.Client”
$Sitecode = $Sitecode.GetAssignedSite()

$computer = $env:COMPUTERNAME
$namespace = “ROOT\SMS\site_$Sitecode”
$classname = “SMS_PXECertificateInfo”
$NotifyDays = 60

$NotifyDays

<#
Creates the Eventlog source if not exist
Script will fail with this error, if not executed as admin.


Exception calling “SourceExists” with “1” argument(s): “The source was not found, but some or all event logs could not be searched
. Inaccessible logs: Security.”

#>

if ([System.Diagnostics.EventLog]::SourceExists(‘SCCM SCRIPTS’)) {
Write-host “SCCM SCRIPTS” exist already
}
Else {
New-EventLog –LogName Application –Source “SCCM SCRIPTS”
Write-host “SCCM SCRIPTS” Created
}
$PxeData = Get-WmiObject -Class $classname -ComputerName $computer -Namespace $namespace |
Select-Object __SERVER,@{label=’ValidUntil’;expression={$_.ConvertToDateTime($_.ValidUntil)}}, @{Label=’IsBlocked’;Expression={$_.IsBlocked}} |
Where-Object {$_.IsBlocked -eq $False}

ForEach ($pxeComp in $PxeData){

$Eventmsg = “”

# get the difference between $pxedata and today
$dif = NEW-TIMESPAN –Start (Get-Date) –End $pxeComp.ValidUntil
$Daysleft = $dif.Days

If ($Daysleft –lt $NotifyDays) {
$Eventmsg = “Pxeboot Certificate is about to expire at $pxeComp : $Daysleft left before is expires, Renew the certificate at the SCCM console”
Write-EventLog -EventId 999 -LogName Application -Message $Eventmsg -Source “SCCM SCRIPTS” -EntryType Error
Write-host $Eventmsg
}
Else{
$Eventmsg = “Pxeboot Certificate date i still valid at $pxeComp : $Daysleft left ”
Write-EventLog -EventId 998 -LogName Application -Message $Eventmsg -Source “SCCM SCRIPTS” -EntryType Information
Write-host $Eventmsg
}
}

$NotifyDays

#Script end

SCCM 2007 – Where is my Collection??

Tags

I found this excellent post about finding a collection in the SCCM 2007 hierarchy.

http://myitforum.com/myitforumwp/2011/09/11/sql-query-to-show-location-of-collection-objects-in-admin-console-folders/

DECLARE @CollectionID AS varchar(8)

DECLARE @Path AS varchar(2000)

SET @CollectionID = ‘MAS01469’
;
WITH colCTE (row, collectionID, Name, parentCollID)
AS
(
SELECT
1
,sub.subCollectionID
,col.Name
,sub.parentCollectionID
FROM
v_CollectToSubCollect sub
INNER JOIN
v_Collection col ON sub.subCollectionID = col.CollectionID
WHERE col.CollectionID = @CollectionID

UNION ALL
SELECT
cte.row + 1
,sub.subCollectionID
,col.Name
,sub.parentCollectionID
FROM
v_CollectToSubCollect sub
INNER JOIN
v_Collection col ON sub.subCollectionID = col.CollectionID
INNER JOIN
colCTE cte ON cte.parentCollID = sub.subCollectionID
)

SELECT @Path = COALESCE(@Path + ‘\’, ”) + Name from colCTE WHERE row > 1 ORDER BY row DESC

SELECT
@CollectionID AS ‘CollectionID’
,col.Name,
CASE
WHEN @Path IS NULL THEN ‘ROOT’
ELSE @Path
END AS ‘Path’
FROM
v_Collection col
WHERE
CollectionID = @CollectionID