Wednesday, April 9, 2014

Igap releases CRM-Pack: always keep your CRM up-to-date (UPDATE: VIDEO)

Igap just released Igap Missito CRM-Pack to let you keep your Dynamics CRM Business Units and CRM Users always up-to-date with the corresponding AD security groups. It also allows your employees to request the membership they need by themselves forcing any of the the CRM Business Unit owners to approve the requests. The Igap Missito CRM-Pack updates the AD-groups automatically and makes sure the Dynamics CRM gets synced on preferrable schedule.

Highlights:
  • Move CRM management from CRM to Active Directory and let Missito CRM handle groups and sync changes to CRM.
  • Request new CRM Business Units with automatic creation of the corresponding AD-groups and owners.
  • Request membership in CRM Business Units
  • Approve requests for membership as the owner of CRM Business Units.
  • Creation of CRM Users when users are approved as members but has not been CRM Users before.
  • Inactivation of CRM Users when users are removed as members to avoid being charged for CRM Users that are not beeing used.
  • Inactivation of CRM Business Units when cancelled (AD-groups are removed)
More information:
Product sheet are available here: Product sheet >>
More info available here: Igap.se >>

Igap Missito CRM-Pack is available stand-alone but can easily be upgraded to the complete version of Igap Missito that can publish arbitrary services with self service and complete automation.

Igap Missito CRM-Pack

UPDATE: Video:

Thursday, March 20, 2014

Time is running out for XP - tips for cleaning up

Since Windows XP support officially ends on April 8, 2014 it's high time to get your statistics up to date. In my latest post Migrating windows best practices the focus was primarily to set things up and ready for migration. Now as the time is running out, hopefully you've managed to get most of your XP's up to Windows 7.

Even thought most computers are done there might be a few hiding out there for more or less good reasons. Involved in the migration you'd probably be interested in finding them to eventually close your migration.

In the project I've been working with we've built features like that into the migration web application but in other cases there might be more manual procedures and the other day I came across two powershells that would help you find which computer and users to focus on.

Ashley McGlone posted a great powershell for finding active computers in Active Directory, still running XP:
Use powershell to find windows xp computers still alive in your active directory domain
Combine that one with another powershell from Clint McGuire and you probably will have a great base to finish up your migrations!
Powershell script to get all computers last logon time

Worth mentioning is also that Igap has a neath self service mangement portal in which powershells (or Runbooks) are easily imported into workflows that you can connect to services you create yourself and publish to your users in no time.

Tuesday, January 21, 2014

Migrating Windows – Best practice tips and tricks


Background

For the past year I've been involved in a migration project at a company with +10’ employees, spread over +20 countries. During the project my role was initially to be responsible for the infrastructure and processes required to make it possible to migrate +15’ computers without local technicians. After the infrastructure role I got responsible for roll-out which is also the role that I've got at this moment. Today we’re migrating 100-250 computers a day rather effortlessly. Sure there is a computer or two every now and then with a hick-up but all in all I must say I’m proud being part of what we have accomplished.

Now the road to get to this point hasn't been bump-less all along. Many lessons have been learned and this post is an attempt to share these lessons.

Set your plan and structure

In a big migration project across an entire company splitting the organization in to pieces is necessary, otherwise planning migrations will be a mess. In this specific project we used departments as the key to decide where to migrate and when. One common phenomenon at many companies is to register computers to departments. This is – in my opinion – risky due to the fact that departments pops-up, get new names or are removed which could lead to computers hanging loose without a belonging. Instead register your assets to your employees which will make it much easier to identify and take actions when users with registered assets leave. Also when departments disappear or get new names, the employees will most likely get their new department information from day one.

Roles and information

Set up the roles you need like department CP (contact person), User (recipient of migrated computer)
Set up your information plan but don’t overdo it. Gather “good to know”-info in one place (use the same web-application?) and decide when to notify users and what to tell them.

Establish your project data source

In the beginning of this particular project the idea was to send a list with computers and their belonging (employee -> department) to each CP at every department, asking the CP to confirm that the computers are registered correctly. Now with X thousands of departments it was soon obvious that the work-load to handle those excel-documents was going to be overwhelming. Also in case of computer ownership changes, department changes or employees moving or quitting there would be absolute chaos. We figured the best way was to set up a web-application with the information needed that published each department with the employees and their computers. Syncing the organization information would also lead to automatic updates of what computers that belongs to what department. Additionally each computer was also made schedulable in order for CP  to choose the date at which a specific computer should migrate.

Identify and automate your migration processes

When the time comes and a computer is about to migrate a bunch of tasks have to be performed. Although the tasks vary from case to case the tasks are probably supposed to be done in the same manner every time. That’s a perfect set up to automate things so start by identifying the steps needed for a successful migration. I.e. send information mail T-x, move computer, add/remove computer to groups or collections, move user, add/remove user to groups or collections etc etc.

Implement your processes

Set up a scheduled job to perform the tasks needed at the time when a computer is scheduled. A reliable workflow engine is an advantage and from my experience I can recommend both Igaps iWorker (part of Igap Missito) and Microsofts Orchestrator where iWorker is highly flexible, has extensive logging possibilities and Orchestrator is a great engine even if it’s a little more slow rowing and may be a bigger investment if not already in place. Add your user information notifications to the scheduled job according to your information plan. 
In this specific project we moved both computers and groups, added and removed different groups and prepared SCCM (Microsoft System Center Configuration Manager) with both Windows installation and application prerequisites.

Monitoring and follow-up

Migrating many computers every day could generate an extensive back-log if problems aren’t dealt with right away. To be able to see what went well and what didn’t we used a lightweight web-application called Igap SDO to monitor the deployments in SCCM. With the web application we were able to see what migrations that went well, what migrations that were currently running and what migrations that had gone wrong. Additionally for the ones that went wrong the logs are available for the SCCM people to identify issues in the migration process, correct them and check that they were actually resolved.
Another important feature is to make sure that all the scheduled jobs that run logs exactly everything. This will be a great help during the migrations to be able to track down every single step in the process that can be improved. 
Igap SDO

Application mapping

Since we identified and implemented the processes needed, made some small corrections along the way the workload decreased dramatically after a while. The time released could then be used to improve things further. One thing that was much appreciated was the automatic application mapping addition to the migration process. Most of the applications were and are re-packaged for the new platform. Some of them easier others a little more difficult. The application mapping addition was included to make sure that the user got the applications for the new platform that corresponded to the applications he or she on the old platform. I think the addition made the questions a lot fewer and the employee satisfaction a lot higher. It was all set up in a database with the old and the new application mapped to each other and then used in a step in the scheduled migration job.

Extra extra

We’ve accomplished more great stuff in the automation of migration process but they would be more suitable for a book since this post is already too long. But feel free to contact me if you have any questions or want to now more!


Wednesday, May 1, 2013

Solve ps-drive problem with SCCM2012 sp1 powershell script


I was trying to run a powershell script on a SCCM2012 sp1 machine and couldn't get it to work. After importing the Configuration module I just couldn't access the powershell drive. The problem only occured when trying to use a service account. With my normal admin account everything was working fine. This led me to believe  that it was access permission problems but no, that was a dead end.

Here's what i was trying to do:
Import-Module ‘c:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1’
Cd ps1:
Remove-CMDevice -DeviceName $computername -force

The errors I got was:
Cannot find drive. A drive with the name 'ps1' does not exist.

This command cannot be run from the current drive. To run this command you must first connect to a Configuration Manager drive.

The only problem here was that "get-psdrive" didn't return any ps1: drive that i needed.

Finally I found the error. It seems that starting powershell from within the Configuration Manager Console once registers the ps-drive for the current user account. Here's how you do it

1. In Configuration Manager Console click "Connect via Windows PowerShell"

 2. Type A for "Always run"


All done!

Wednesday, April 17, 2013

Simple way to compare two datarow objects C#

DataRow dr1 = ..

DataRow dr2 = ..

IEqualityComparer<DataRow> comparer = DataRowComparer.Default;

bool isMatch = comparer.Equals(dr1, dr2);
 
Enjoy!

Tuesday, April 2, 2013

MMS 2013 - Las Vegas

MMS 2013 is closing in with only one week to go until show time. We're looking forward to see what news will come from the giant software company, it will be particularly interesting to see third party IT automation and self service solutions.

We'll be back with some posts live from the event!

Tuesday, September 25, 2012

Get to the Attribute Editor in AD Users and Computers without browsing for the user

The "Attribute Editor" tab in Users and computers is very useful in many ways. The only big disadvantage with it is that it doesn’t show when searching for objects and opening properties from the search result list.

To show the tab I used to open the object from the search results, get the path from the object tab and then browse down the AD tree to open it from its location. Not fast, neither fun.

I accidently discovered another way to get the Attribute Editor to show, which is to open the properties of an object from another object. In other words, open the properties for a user by opening the properties from the members list of a group that the user is member of. This only works when the user is closed and opened from the group, so the workaround is:
1. Search the object you want to see properties for.
2. Open the member of tab and display properties for one of the groups that the user is member of. Try to pick a group with few members.
3. Close the properties for the user.
4. Open the properties for the user by double click the user name in the members list of the group you opened in the second step.
5. Taa-daaa. The Attribute Editor tab is shown!

Sound very complicated, but is way faster than browsing the user.

Remember that the Attribute Editor is only shown if the advanced features are enabled in ADUC (View -> Advanced Features).

Wednesday, April 4, 2012

Quicktip of the day: Visual studio and clipboard (copy/paste)

Working with Visual Studio will give you both good and bad days. This tip may give you one or two more of the good ones.

Visual studio automatically stores your copy/cut commands up to 10 times. This means that you've not only the possibility to paste the last word that you copied or cut, but the 10 last ones.

To use this feature simply use [Ctrl + Shift + V] instead of [Ctrl + V] and keep hitting to go back through your copy/cut history.

Enjoy!

Tuesday, April 3, 2012

GridView, List of objects and sorting

Binding a GridView to a list of objects is a neat way to expose your data through Entity Framework. Now sorting a List of objects could be a bit tricky if you want it to be dynamic. In this scenario Linq and Lamdba offers great possibilities to achieve your goal.

1.  Add using statement:
using System.Linq.Expressions;
 
2.  Define your gridview and set the event “onsorting”.
<asp:GridView ID="myGridView" runat="server"...
                    onsorting="gridView_Sorting">

3. Set up your sorting method:
protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
{
        //Get the datasource and last sortDirection (enum (int) in this case):
     List<YourObject> yourObjects = CurrentDataSource;
     int currentSortDirection = CurrentSortDirection;
         if (yourObjects != null)
     {
                 //Use the e.SortExpression to order the list of objects
          var param = Expression.Parameter(typeof(YourObject), e.SortExpression);
          var sortExpression = Expression.Lambda<Func<YourObject, object>>(Expression.Convert(Expression.Property(param, e.SortExpression), typeof(object)), param);
                
                 //Set the list ordered ascending as datasource
         if (currentSortDirection == (int)SortDirection.ascending)
         {
                myGridView.DataSource = yourObjects.AsQueryable<YourObject>().OrderBy(sortExpression);
         }
        
             //Set the list ordered descending as datasource
         else
         {
                  myGridView.DataSource = yourObjects.AsQueryable<YourObject>().OrderByDescending(sortExpression);
         }
         if (currentSortDirection == (int)SortDirection.ascending)
            CurrentSortDirection = (int)SortDirection.descending;
         else
            CurrentSortDirection = (int)SortDirection.ascending;

         myGridView.DataBind();
     }
}
4. Your all set. Good luck.

Tuesday, March 13, 2012

Invert scroll wheel direction in Windows

When I first installed Mac OS X Lion I had a bit of a struggle accepting that the scroll direction was inverted. But I gave it a chance and soon realized that the “new” way of scrolling felt much more natural, the pages are scrolled by pulling the page down and not the scrollbar – just like on a smart phone or tablet. Getting used to it have a backside though, it gets confused again when working in Windows where the scroll isn’t inverted. Windows doesn’t have any GUI to change the scroll direction, but it’s a pretty simple change in the registry to change it.

Browse the key “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\HID\”:

Here you will find a collection of keys named something like “VID_xxxx&PID_xxxx”.Each key contains settings for different input devices. To find out which key contains settings for your mouse, open the device manager and check the properties for the mouse. In the Information tab select Hardware-ID and a list of IDs will show – and one of these has the same name as the key you are looking for in the registry. Now expand that key and go through all subkeys and look for a leaf node key called “Device Parameters”. Look for the attribute “FlipFlopWheel” and change the value from 0 (default) to 1. Reboot might be necessary.

Wednesday, February 15, 2012

Check all ASP CheckBoxes within an ASP Repeater with JavaScript to avoid PostBack

Problem:





I created my own CheckBoxList with an ASP Repeater that contained several ASP CheckBoxes and some labels. I also wanted to have the function to check and uncheck all the checkboxes within the repeater. This was easy to do with an OnCheckedChanged=”SomeCodeBehind” and AutoPostBack=”true” on the design file. This gave a working result but since it made a post back each time, the control flashed for a quick second every time the checkbox was clicked and sometimes even gave me time enough to click on the checkbox multiple times. In other words, it gave an impression of a slow application.

The next problem appeared when this controlwas inserted in to an AJAX Modal Popup window. Whenever the control made a postback the modal popup was closed. A solution would be to make an EventHandler for each time the checkbox is clicked, in that way the event could be caught within the parent control and trigger a function to reopen the modal popup again. But since this event is not needed in any other situation this solution felt a bit to much.

Solution

Javascript! But the first question that arised was "How to get hold of all the elements within a repeater?" Well it is not that complicated actually. First of let me show the design of my repeater:

HTML:




<div id="Div_CheckBoxList">
<asp:repeater id="Repeater_CheckBoxList" runat="server">
<headertemplate>
<table id="Table_CheckBoxList">
<tr>
<th>
<asp:checkbox id="CheckBox_CheckAll" runat="server"></asp:checkbox>
</th>
<th>
<asp:label id="Label_CheckAllText" runat="server" text="Check/Uncheck all"></asp:label>
</th>
</tr>
</headertemplate>
<itemtemplate>
<tr>
<td>
<asp:checkbox id="CheckBox_RepeaterItem"></asp:checkbox>
</td>
<td>
<asp:label id="Label_CheckBoxText" runat="server"></asp:label>
</td>
</tr>
</itemtemplate>
</asp:repeater>
</div>




And now to the magic! Here is the javascript function checkAll that checks and unchecks all the checkboxes within the repeater. It obtains the client ID (since we are working with ASP controls) of the element that contains all the checkboxes. It could be a panel or a div, but in this case we use the repeaters client ID.

All the elements within this "container" are then extracted and iterated through. What we are looking for is an element with an ID that contains the word "checkbox". And we also know that the first checkbox that we will find (since it is furtherest up in the page) is the "check/uncheck all"-checkbox. The interesting thing about that checkbox is to know if it is checked or unchecked to be able to check the rest equally. And that would be all!

NOTE! You maybe ask yourself why we do not get all the elements from the document, document.getElementsByTagName('*') instead? Well that is because sometimes there might be other checkboxes on the page, or in my case I want to be able to introduce two repeaters on the same page, without clicking the "check/uncheck all"-checkbox on one repeater also affects the other one.

JavaScript



function checkAll(containerClientID) {
var repeater = document.getElementById(containerClientID);
var all = repeater.getElementsByTagName('*');
var found = false;
var isChecked = true;
for (var i = 1; i < all.length; i++) {
var e = all[i];
if (e.id.toUpperCase().indexOf("CHECKBOX") != -1) {
if (found) {
e.checked = isChecked;
}
else {
isChecked = e.checked;
found = true;
}}}}


To be able to use this javascript following change must be done on the HTML code:

HTML



<asp:CheckBox id=&quot;CheckBox_CheckAll&quot; ...
onClick='<%# "javascript:checkAll(\"" + this.Div_AlternatingTable.ClientID + "\");" %>'
... />


The following code is for making only one checkbox in the repeater to be able to be selected simultaniously.

JavaScript



function checkOne(containerClientID, checkboxIndex) {
var repeater = document.getElementById(containerClientID);
var all = repeater.getElementsByTagName('*');
var currentCheckboxIndex = 0;
for (var i = 1; i < all.length; i++) {
var e = all[i];
if (e.id.toUpperCase().indexOf("CHECKBOX") != -1) {
if (currentCheckboxIndex != checkboxIndex) {
e.checked = false;
}
currentCheckboxIndex++;
}}}


And the following changes need to be done on the HTML

HTML



<asp:CheckBox id=&quot;CheckBox_RepeaterItem&quot; ...
onClick='<%# "javascript:checkOne(\"" + this.Div_AlternatingTable.ClientID + "\",\"" + Container.ItemIndex + "\");" %>'
... />

Wednesday, February 8, 2012

Quick tip: PopupControlExtender displays popup in wrong position



When using multiple PopupControlExtenders in a page the positioning of the popup panels might get a little bit shifted, as shown in the filter example. (Using Position="Bottom")







One way to make sure this doesn't happen is to always set a css-class with the style "display: none;" on all panels that will be used as popups. This will fix the alignment, and will also remove the flicker of the control when loading the page:

Using System Center Orchestrator 2012 to monitor folders

One big drawback with the existing "Monitor Folder" activity in System Center Orchestrator 2012 RC is that it will only trigger on files dropped while your runbook is actually running. That means that if you temporarily stop your runbook to do an adjustment, all files that some other system drops in your folder while doing this will be ignored when you start your runbook again.

It's pretty easy to avoid this by instead scheduling a powershell script that returns all files in your folder.
Here's a simple example:

Start by adding a Monitor Date/Time activity and set an appropriate polling interval. I'll set mine to 1 minute.


Next add a "Run .Net Script" activity and link that to the monitor acitivity. Select PowerShell as language and paste this into the script window (modify it to your own lab folder). The *copy* file mask is by the way a handy tip when developing these kind of workflows. Using this you will be able to keep a file in your dev directory and just copy-paste it in the same directory to kick your workflow.

$FileName = (Get-ChildItem c:\temp\lab\*copy*.xml) | Select-Object FullName
$Count=@(Get-ChildItem c:\temp\lab\*copy*.xml).Count

The $Count parameter will be used to decide whether or not to continue and the $FileName parameter will be used to perform some kind of operations on that file.



Now set the data that will be published:


Now you're all set to continue building your runbook. In my example i will just copy the file to another location. On the link set the following condition




Now add the copy file activity. 

As you may note I do a little magic on the FileName parameter…Here’s a better view on that




This is what my runbook looks like. I also log when no files are found in this example (set NumberOfFiles equals 0 on the link if you want to do that as well)


Thursday, October 13, 2011

Using SCCM client center functionality to import local policy

Tired of waiting for collection evaluation and policy updates when advertising programs in SCCM? There is a function in SCCM client center that imports local machine policies, but it requires that an elevated user runs the program and there is not batch functionality.

By referencing the smsclictr.automation.dll this functionality can be reused to build workflow activities/batch programs that calls the same logic as SCCM client center uses. Example code:


SMSClient client = new SMSClient(computerName);
client.Connection.Connect();
if (client.Connection.mScope.IsConnected)
{
//Connect to the clients managementPoint SQL server
SqlConnectionStringBuilder sqlConnectionBuilder = new SqlConnectionStringBuilder("Integrated Security=True");
sqlConnectionBuilder.DataSource = client.ManagementPoint;
sqlConnectionBuilder.InitialCatalog = "SMS_" + client.SiteCode;

SqlConnection sqlConnection = new SqlConnection(sqlConnectionBuilder.ToString());
try
{
sqlConnection.Open();
SqlCommand command = new SqlCommand();
command.CommandText = "SELECT PolicyID, Body FROM Policy WHERE (PolicyID LIKE '%" + advertisementID + "%') ORDER BY PolicyID";
command.Connection = sqlConnection;

SqlDataReader dataReader = command.ExecuteReader();
while (dataReader.Read())
{
byte[] policyBody = dataReader[1] as byte[];
client.SoftwareDistribution.ImportSCCMPolicy(policyBody, false);
Logging.Log("Policy imported on computer '" + computerName + "' (AdvertisementID: " + advertisementID + ")", System.Diagnostics.EventLogEntryType.Information);
break;
}
sqlConnection.Close();
}
catch (Exception ex)
{
Logging.Log("Failed to get policy from SQL for advertisement '" + advertisementID + "'. Error: " + ex.ToString(), System.Diagnostics.EventLogEntryType.Error);
}
}

Thursday, August 11, 2011

Disable XP security warning (to avoid hanging SCCM advertisement)

When running a install program, some times the XP security warning blocks the advertisement from running. The dialog box should only popup for applications starting from an "untrusted" source, and including the path as trusted in IE should disable that check.

For some reason, this does not seem to make any difference at all times. The popup blocks the program and the advertisement will eventually time out and fail.

To avoid this the security check can be disabled before running the program and re-enabled when its done by calling the setup from a vbscript. In the script below the exit code from the program is parsed to translate the exit code from the vendors "reboot needed" to 3210 which is the code SCCM uses to wait for reboot.



Option Explicit
Dim oFSO,oWsh,oEnv
Set oWsh=CreateObject("Wscript.Shell")
Set oFSO=CreateObject("Scripting.FileSystemObject")
Set oEnv = oWsh.Environment("Process")

Dim sProgram
sProgram = GetPath(Wscript.ScriptFullName) & "\Setup.exe"

If oFSO.FileExists(sProgram) Then
'Disable the security warning when starting the program
oEnv("SEE_MASK_NOZONECHECKS") = 1
Dim sCmd
sCmd = """" & sProgram & """ -s -overwrite"
wscript.echo sCmd
Dim iRet
On Error Resume Next
iRet = oWsh.Run(sCmd, 0, True)
'Enable security warnings
oEnv.Remove("SEE_MASK_NOZONECHECKS")

If Err Then
Wscript.Quit iRet
End If
If iRet = 14 Then
Wscript.Quit 3010
End If
Wscript.Quit iRet
Else
Wscript.Quit 1
End If

'*********************************************************
' Purpose: Return Path for filename
' Inputs: FullFileName
' Returns: PathName
'*********************************************************
Function GetPath(FileName)
Dim iPos

iPos=InStrRev(FileName,"\")
If iPos>0 Then
GetPath=Mid(FileName,1,iPos-1)
Else
GetPath=FileName
End If
End Function

Sunday, June 26, 2011

Automated self-service and identity repository


Many companies are putting a lot of effort in managing their identity repository which is supposed to represent the current user and organizational information. Keeping the identity repository up to date is often time consuming and hard work since organizations is constantly transforming. New employees are introduced, existing employees move between business units and some quit. Moreover the organizational structure transforms in the same way adding yet another dimension of complexity.

Some companies have succeeded in managing this type of identity repository to a desirable degree. Some may even have succeeded in doing this with technical, automated solution that doesn’t even require people behind the controls. If you are not part of one of these organizations I hope that this post will bring a new perspective to the situation and contribute on your path towards a fully automated and managed identity repository.

Now the identity repository is merely one part of the two key components in this post. The other one; self-service is the other. I won’t preach about self-service in itself (I'll do that later) but rather bring it up in relation to the identity repository. A self-service solution is often built on top of, and dependent on, a more or less existing architecture of which the identity repository is one part. When introducing self-service some may have the perception that the identity repository have to be complete in order to succeed. That is the perception that I don’t share and would like to put in different light. The reason is my belief of synergy between these two rather complex parts in which the self-service solution could contribute in bringing the identity repository closer to a complete state.

Standardize the input controls in the self-service solution, require user input and validate the data as much as possible. Then use the information to fill the gaps in the identity repository and let it apply until there is a more reliable way of retrieving information with higher quality.          

Letting the user repository be updated in parallel with the introduction of a automated self-service solution you will:
1. Get started with the self-service solution independently of the quality of the identity repository, giving the employees the possibility to gain from the self-service solution benefits.
2. Get your identity repository updated and closer to a complete state until a better way of doing this exist.

The degree of options for the employees and validation of input is- of course – determining the quality of the information brought in from the employee.

Either if you are an employee of one of the companies that have a complete identity repository or if you’re fighting problems on your way getting there, I think that you are in the possession of many great experiences and knowledge in this topic. In that case I welcome your feedback and encourage you to stay tuned and keep in touch to discuss more on this topic.