Skip to main content

Posts

Showing posts with the label Automation

PowerShell + AzureRM : Automated login using Service Principal

Do you remember ? In the older Azure Service Management model, we had an option to import the publish settings file and use the certificate for authenticating. It saved a lot of hassle. That method is deprecating now but we have something better which we can use in the newer ARM model. BTW for record I find it really annoying to enter credentials each time when I want to quickly try something out on Azure. So I have been using two techniques for automated login to the AzureRM portal. Storing Service principal creds locally (encrypted at rest using Windows Data Protection API) and using that to login. Using Certificate based automated login .

PowerShell + SCCM : WMI Scripting

Why should I use WMI, when there is a PowerShell module available for Configuration Manager (CM Module) already? Well the cmdlets behind the scene interact with the WMI layer and if you know which WMI classes the corresponding cmdlet work with , it can be of help in future by : Switching to native WMI calls when the CM cmdlets fail for some reason (probably bug in the CM Module). Making your scripts more efficient by optimizing the WMI (WQL query) calls, the cmdlet will query all the properties for an Object (select *) you can select only ones you need.  Lastly no dependency on the CM Module, you can run these automation scripts from a machine not having the CM console installed (needed for CM module). Moreover ConfigMgr uses WMI extensively, you already have this knowledge leveraging it with PowerShell shouldn't surprise you. This post assumes you have been working with CM cmdlets (you already are versed with PowerShell), know where the WMI namespace for ConfigMgr resides ...

PowerShell + SCCM - POSH Deploy v1

I wrote an article for the coveted PowerShell Magazine on how to automate query based deployments in ConfigMgr using PowerShell. http://www.powershellmagazine.com/2014/07/22/automating-deployments-in-configuration-manager-with-powershell/ If you go through that article you will get a background of this post. So continuing to that, I present " POSH Deploy v1 " which can be used to automate Query Based deployments with Configuration Manager (tested it on CM 2012 only). I had a similar tool built in my previous project for SCCM 2007 but that one had a lot of hard coded values, tried to remove those. The tool earlier used Winforms and this time I kicked myself to try out WPF with PowerShell . Thanks to StackOverflow and blog posts shared around these topics by awesome community people :)

PowerShell + SCCM 2012 R2 : Adding Roles & Client Settings (Device & User)

Post #3 in the PowerShell with ConfigMgr 2012 series. Trying to do the things mentioned in this post --> @ Windows-Noob Before I begin, I had an interesting discovery. While trying out the Cmdlets in the ConfigurationManager Module, I had been facing a lot of issues....like in the Discovery Post few weeks ago was not able to use the -ActiveDirectoryContainer parameter. So had to resolve to WMI way. When I was trying out things mentioned in this post with PowerShell I faced a lot of Errors and asked around, finally was able to get a workaround. I have ConfigMgr 12 R2 Preview installed on the server and the Eval version is out. So I downloaded the ConfigMgr 12 R2 Eval version and just did a re-install of the ConfigMgr Admin Console on one of my machines. Now the downside of this is the GUI won't connect to the Site Server because of the version mismatch but the PowerShell module works fine (this is what I was after). I still have old ConfigMgr Admin Console installe...

PowerShell + SCCM 2012 R2 : Extending Discovery; Create Custom DDRs

While working on the previous post on exploring Discovery methods with PowerShell I came across this awesome post on creating custom DDRs with PowerShell in ConfigMgr07. http://marcusoh.blogspot.in/2010/10/sccm-custom-data-discovery-records-ddrs.html The above post explains how to create custom DDRs using ConfigMgr SDK for ConfigMgr 07. So I got tempted to immediately try it out in my ConfigMgr12 environment and found out that there exists another cool way shown by Adam Meltzer  (using C#) in his blog to create DDRs in ConfigMgr12. So in this post will try to cover : Create DDRs using COM Interface (DLL used : smsrgenctl . dll ) Create DDRs using the new DiscoveryDataRecordFile Object Interface (DLL used:  Microsoft.ConfigurationManagement.Messaging.dll ) Note : Both the above DLLs are part of ConfigMgr 2012 SDK. Create DDRs using COM Interface (DLL used : smsrgenctl.dll) Tried loading the smsrgenctl.dll from PowerShell using Add-Type , System...

Use PowerShell to remove packages from the Distribution Points

This post is inspired by one of the activities which we had to recently do. We have a lot of branch DP's where we want to cleanup all the obsolete packages (which are not used anymore). This can be done manually by going in the ConfigMgr Console Packages node and updating the DP's manually for each package. But where is fun in doing that ...Lol I couldn't find much on the internet ..So I tested it in my Lab first and then in QA in our environment and then did it in PROD. For this post demonstration I am showing this on my LAB (ConfigMgr12) but it does work with ConfigMgr07. Note - ConfigMgr 2012 R2 has this cmdlet  Remove-CMContentDistribution which can do this but am showing the method which will work with all ConfigMgr versions (hopefully). Right now I have distributed 3 packages to the only DP (DexSCCM) in my environment. Now we can get the same Information about which DP the particular package is Distributed by querying the SMS_DistributionPoint Class. ...

PowerShell + SCCM 2012 R2 : Discovery

So my lab is all setup. Now before starting to manage Objects (Computers, Users etc. ) we need to discover them. If you want to read more on Discovery in ConfigMgr, you can browse to this link . For this post am trying to automate things done in this post at Windows-Noob . Note - To manage ConfiMgr using PowerShell one needs the ConfigrationManger Module (this is available after you install Admin Console on a Client/ Server) loaded in the session, which can be done in two ways: You can open a PowerShell session and import the ConfigurationManager module. Import-Module -Name "$(split-path $Env:SMS_ADMIN_UI_PATH)\ConfigurationManager.psd1" Using ConfigMgr Admin Console you get an option to connect using PowerShell which essentially does the same thing done in above step. Note: To run all the CM Cmdlets your location needs to be set to the CMSite and properties you reference are case sensitive. Below is the Screenshot showing that : Now see th...

PowerShell + SCCM 2012 R2 : Installation

Recently decided to embark on this little adventure of mine...where I will setup my SCCM 2012 R2 Lab and try doing most of things using PowerShell. I know this is ambitious and might take longer (even longer to blog about it)......But that hasn't stopped me in past. I am sure I will learn a lot in the process. So for this post it is the installation am focussing on and I am following the Windows-Noob Guide here . Steps which I won't be doing using PowerShell will be mentioned. My LAB : 1.  DexterDC   --  Domain Controller [Domain name - Dexter.com] (server 2012 R2) 2. DexSCCM -- Machine where SCCM will be installed (Server 2008 R2) 3. DexClient -- Windows 7 Client To make my Quest easy, I have enabled PSRemoting in the Domain using GPO. Step 1. Create the Lab Environment Create AD Users First let's create the Users and then try to give the permissions needed. * SMSadmin, a domain user  * Testuser, a domain user * Testuser2, a domain user * T...

[PowerShell + WMI Eventing ] AD Group Modified --> Run a PowerShell Script

I knew it would be a great learning opportunity when Francois-Xavier Cat Sir  agreed to take me in his team for the Winter Scripting Games this year. FX Sir posted about this great Script which will monitor your AD Group for any changes and then email you the changes if any. You can find the blog post here Now while reading the post I had a question...So I did comment on the post there: Well until recently I found out that it could be done very easily. So in today's blog post I will show how to trigger a PowerShell Script when a Group in AD is modified. I got the answer to above question while reading this great book on WMI by Ravi Sir suggested to me by Laerte Junior Sir .  You can find the book here If you haven't guessed it by now the answer to making it possible is --- Wait for it " WMI Eventing ". I read this very cool thing on a blog:                  "The M in W M I stands for Magic"  - Ki...

SCCM 2007 + PowerShell -- Final Post

This is the last post on the SCCM 2007 + Automation Series in this blog. I will share the Script with which I was able to achieve automation of the Query Based Deployments. Finally using this Script I can Add machine names to the Query Membership Rule in a Collection...thus freeing myself of the GUI clicks needed in ConfigMgr Console. So I have a test collection by the name "Deepak test 1" and what I have done is removed all the Query Rules from it to show how the Script works. So Initially the collection has no Query membership rules, as evident from below screenshot of the Collection Properties in the ConfigMgr07 console: And below is a count of no of members inside the collection...No members I will be using the SCCM-Commands PowerShell module for my Script , I did cover some parts of it in previous post So I will describe the logic quickly.....I have a Function named Add-MachineToSCCMQueryRule which is the Function which will add specified machine na...