Create a somewhat random collection using SMSUniqueIdentifier
This query will allow you to create a somewhat random collection based on the SMSUniqueIdentifier add more or less numbers depending on your target deployment size
1 2 3 4 5 6 7 8 9 |
select SMS_R_SYSTEM .ResourceID ,SMS_R_SYSTEM.ResourceType ,SMS_R_SYSTEM.Name ,SMS_R_SYSTEM.SMSUniqueIdentifier ,SMS_R_SYSTEM.ResourceDomainORWorkgroup ,SMS_R_SYSTEM.Client from SMS_R_System where SMS_R_System.SMSUniqueIdentifier like "%[012]" --from SMS_R_System where SMS_R_System.SMSUniqueIdentifier like "%[0123456789ABCDEF]" |
SCCM Client Install – Could not access network location %APPDATA%
Today I was troubleshooting an SCCM Client install issue. checking the CCMSetup.log file the setup was returning “Could not access network location %APPDATA%” To resolve this issue I updated the appdata location under the following registry key
1 |
HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders |
the location was set to “%APPDATA%” instead of “%USERPROFILE%\AppData\Roaming” after updating this location I was able to successfully […]
SCCM SQL query to list deployments with User Notifications set to show all
Today I needed get a list of deployments that had the user notification set to “Display in Software Center and show all notifications” so I could update the deployments so users would not get the “New Software is Available” toast on available deployments. I was able to use this query to determine this.
1 2 3 4 5 6 |
SELECT [AssignmentName] ,[CollectionName] ,[NotifyUser] ,[EnforcementDeadline] FROM [vSMS_AssignmentBase] WHERE (NotifyUser='1' AND EnforcementDeadline Is Null) |
[…]
Purge Transactional dead-letter queue messages using PowerShell
Here is a snippet I used to purge messages from the System Transactional dead-letter queue using PowerShell.
1 2 3 4 |
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") $msmq = [System.Messaging.MessageQueue] $queuetd = New-Object $msmq("FormatName:Direct=os:.\System$;DEADXACT"); $queuetd.Purge() |
Purge MSMQ Private Queue using PowerShell
I needed to be able to purge all Private Queues using PowerShell. I also needed to have this work on Powershell 3.0. here is the snippet I used to complete this task.
1 2 3 4 5 6 7 8 9 10 |
[Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null $queues = [System.Messaging.MessageQueue]::GetPrivateQueuesByMachine(".")| % { $_.QueueName } foreach ($q in $queues) { $queuename = ".\" + $q [Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null $queue = New-Object -TypeName "System.Messaging.MessageQueue" $queue.Path = $queuename $queue.Purge() } |
with Powershell 4.0 you can use Get-MsmQueue
1 2 3 4 5 6 7 8 9 |
$queues = Get-MsmqQueue –QueueType Private | select QueueName foreach ($q in $queues) { $queuename = ".\" + $q.QueueName [Reflection.Assembly]::LoadWithPartialName("System.Messaging") | Out-Null $queue = New-Object -TypeName "System.Messaging.MessageQueue" $queue.Path = $queuename $queue.Purge() } |
C# Install SCCM Package on Client
I needed to be able to kick of an installation of a SCCM Package on a client from a C# windows form. I discovered the SDKClient WMI Namespace and am using the following code.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
//Populate Listview with Packages try { ManagementObjectSearcher searcher = new ManagementObjectSearcher(wmipath, select); ManagementObjectCollection instances = searcher.Get(); foreach (ManagementObject queryObj in instances) { if (queryObj["FullName"].ToString().StartsWith("Package")) { ListViewItem lvi = new ListViewItem(); lvi.Name = queryObj["FullName"].ToString(); lvi.Text = queryObj["Description"].ToString(); lvi.Tag = queryObj["ProgramID"].ToString() + "^" + queryObj["PackageID"].ToString(); lvi.ToolTipText = queryObj["Description"].ToString(); this.ListView1.Items.Add(lvi); } } } catch { } private void btnRun_Click(object sender, EventArgs e) { try { // Split ProgramID and PackageID out form string string[] progInfo = listTopSolutions.SelectedItems[0].Tag.ToString().Split('^'); programID = progInfo[0]; packageID = progInfo[1]; // Get the object on which the method will be invoked ManagementClass processClass = new ManagementClass(@"root\ccm\clientsdk", "CCM_ProgramsManager", null); // Get an input parameters object for this method ManagementBaseObject inParams = processClass.GetMethodParameters("ExecuteProgram"); // Fill in input parameter values inParams["ProgramID"] = programID; inParams["PackageID"] = packageID; // Execute the method ManagementBaseObject outParams = processClass.InvokeMethod("ExecuteProgram", inParams, null); } catch { } |

Deploying Office 365 using System Center Configuration Manager
This article walks you through preparing and deploying Office 365. Download and install the Office Deployment tools from here. https://www.microsoft.com/en-us/download/details.aspx?id=36778With O365 configurations are done using the Office Deployment Tool for Click to Run and .xml files verses the Customization Toolkit and .msp files that are used in the volume license .msi version Browse to the folder that […]

Creating SCCM User and Device Collections based on Active Directory Groups
Create a User Collection and a Device Collection that pulls its members from an active directory group 1. Make sure you have Discovery set up on your Active Directory or Specific OU containing groups. You can do this by clicking Administration > Discover Methods then right click on “Active Directory Group Discovery” and choose Properties. […]
C# convert WMI DateTime to standard DateTime
WMI Dates and times are in DMTF datetime format. The following is the command to convert a given DMTF datetime to DateTime.
1 |
DateTime Date = ManagementDateTimeConverter.ToDateTime(WMIDate); |
Microsoft Documentation
Configuration Manager 2012 how to add users in an AD group to a user collection
In SCCM the below query string can be used to populate a user collection based on AD group.
1 |
select * from SMS_R_User where SMS_R_User.SecurityGroupName = "DOMAIN\\User_Group” |