Tuesday, May 27, 2014

Tools for SCCM 2012


In this post I'll refer to tools that I usually use in my day-to-day Work with SCCM..


ConfigMgr 2012 Right Click Tools:     

https://www.blogger.com/blogger.g?blogID=4625936282188800349#editor/target=post;postID=1219282707611383650

SMART Documentation and Conversion Helper for your Orchestrator Runbooks:

SMART Documentation and Conversion Helper for your Orchestrator Runbooks

SCCM Client Center:

http://sccmclictr.codeplex.com/

Friday, May 23, 2014

SCCM Manage User Device Affinity (Primary User) with Powershell

This script can be used for setting and removing the primary user of a device.

Change the variables inside the script to your environment and your good to go.

For more information please use the documentation provided in the script so please use the important Powershell commmad GET-HELP :-)

Picture examples are about to be presented at the blog too.. PLEASE WAIT... :-)

Copy the Script or Download it.. Feel free..

Enjoy!!!

Download Script


Or just copy... your choice.


#START OF SCRIPT
#========================================================================

# Created on: 19-05-2014 15:26

# Created by: Flemming Rohde

#========================================================================
 
<#

.SYNOPSIS

 

.DESCRIPTION

This script can add a primary user to a device and remove one or all primary users from a device

Please make sure to change the variables in the variables section!!!

 

.PARAMETER TaskToDo

Can be add or remove and it is the task that will be done

.PARAMETER computername

The computername for which you want to add/remove primary users

.PARAMETER username

The username that will be assosiated with the computer

Provide a PARAMETER section for each parameter that your script or function accepts.

.EXAMPLE

EditPrimaryUsers.ps1 -TaskToDo add -ComputerName yourpcname -UserName domain\username

.EXAMPLE

EditPrimaryUsers.ps1 -TaskToDo RemovePrimaryUser -ComputerName yourpcname -UserName domain\username

.EXAMPLE

EditPrimaryUsers.ps1 -TaskToDo RemoveAll -ComputerName yourpcname

#>
 
 
param( [String]$TaskToDo, [String]$ComputerName, [String]$UserName) #Task must be Add or Remove

#Variables
 
 
 
$SCCMSite = "SITECODE" #The Sitecode of your SCCM

$CMModule = 'E:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\ConfigurationManager.psd1' #Location of Configmanager Module


#Import the SCCM Module
 
 
Import-Module $CMModule


#Variable to CM Drive
 
 
$SiteDir = $SCCMSite + ":"


#change the drive to CM site
 
 
Set-Location $SiteDir



#Set PrimaryUser at the given computer
 
 
if($TaskToDo -eq "Add"){ Add-CMDeviceAffinityToUser -DeviceName $ComputerName -UserName $UserName }



#Removes a single primary user from the device
 
 
if($TaskToDo -eq "RemovePrimaryUser"){ Remove-CMDeviceAffinityFromUser -DeviceName $ComputerName -UserName $UserName}


#removes ALL primary users of a device
 
 
if($TaskToDo -eq "RemoveAll"){ $primaryUsers = Get-CMUserDeviceAffinity -DeviceName $ComputerName

foreach($user in $primaryUsers){Remove-CMDeviceAffinityFromUser -DeviceName $ComputerName -UserName $user.UniqueUserName }

}
#END OF SCRIPT