Posts

Showing posts from February, 2016

Reset Inventory on SCCM client if over 7 days since report

Here is a little script that is a combination of several different pieces I found around the web. Basically it will check a machine and get the last HW & SW inventory dates. Then if those dates are over 7 days it will reset the inventory and trigger a new inventory to occur. Like I said nothing fancy, this script does require admin privs to run. However one could modify it to use the control panel com objects to call the built in inventory cycles like you would through the Configuration Manager control panel dialog. $inventoryQuery = "Select InventoryActionID, LastCycleStartedDate, LastReportDate from InventoryActionStatus" $inventoryResult = get-wmiobject -query $inventoryQuery -namespace "root\ccm\Invagt" $HWdate = $null $SWdate = $null $HWold = $true $SWold = $true ForEach ($iResult in $inventoryResult) {     $inventoryType = [convert]::ToInt32(($iResult.InventoryActionID).substring(35,2), 10)     switch ($inventoryType)     {         1 {

PS Script to convert a PS1 into a HTA that creates and executes a PS1

For one of my earlier posts I made a comment about creating a ps1 that is generated by a hta file and executed. Here is my shortcut script that I use to make the process a lot easier. Also the resulting hta file executes the powershell script in a non admin session and in the native OS architecture. So if you are running a 64bit OS it will make sure to run the 64bit Powershell even though the hta is running in 32bit mode. $a = Get-Content "c:\temp\original.ps1" $b = "c:\temp\original.hta" "<head>"| Out-File -FilePath $b "<title>Application Installation Helper Triggering Script- `${number}</title>"| Out-File -FilePath $b -Append "<HTA:APPLICATION "| Out-File -FilePath $b -Append "APPLICATIONNAME=""Application Triggering Script"""| Out-File -FilePath $b -Append "SCROLL=""yes"""| Out-File -FilePath $b -Append "SINGLEINSTANCE=""yes"&

Updating SCCM Application OS Requirement Rules

As many of you are aware Windows 10 was released, you also know this means that there is a new OS type in the selection dialog. However this also means that if you use OS requirements on your applications you have to go update them to add in Windows 10. Which lets face it, if you have a thousand or so apps, you really don't want to do this all by hand. Since I was faced with this dilemma  I decided to try scripting it. I discovered that it is not as easy as one would expect. After lots of searching and even some help from a friendly PFE. We were able to create something that would get the job accomplished. That being said here are the useful portions of the script that I hope will help you create one of your own that will meet your needs. I will warn you this is not pretty and the full script triggered some crosseye results from my teammates. Yes this is a very long and mostly code post. # Load SCCM Assemblies function Import-SCCMAssemblies { [CmdletBinding()]     param

Mimicking SCCM App Catalog via Powershell

A while back I was tasked with finding a way to script an application deployment that was user based. So basically find a way to do what the native CM 2012 application catalog did without using the catalog web interface. The result ended up being write a powershell that is created on the client machine and called by and hta script downloaded from the "other" store interface. Its not very pretty but it met their requirements. I started my road using very useful information from the CM Team Blog https://blogs.technet.microsoft.com/configmgrteam/2012/09/19/extending-the-application-catalog-in-system-center-2012-configuration-manager/  their blog is an excellent source to help you get your catalog setup so that you can utilize the functions that I'll be using in my examples. From trial/error and debug log reading here is the basic flow of the application catalog interactions and how it works with the client. 1. Get 'AppID' of the application you want to install