Reactivate CRs and all related MAs

The following short script will set a specific CR in progress and all related MAs to active.

$smdefaultcomputer = <computer>
$crclass=Get-SCSMClass System.Workitem.ChangeRequest$
$maclass
= Get-SCSMClass -Name System.WorkItem.Activity.ManualActivity$
$maStatusActive
=get-scsmenumeration ActivityStatusEnum.Active$
$crStatus
=get-scsmenumeration ChangeStatusEnum.InProgress$
$cr
=smlets\get-scsmobject -Class $crclass -Filter “Name -eq ‘CR83769′”
$mas
=Get-SCSMRelatedObject $CR | ? classname -eq ‘System.WorkItem.Activity.ManualActivity’
$masu=$mas | %{$i=$_.id;get-scsmobject -class $maclass -Filter “Id -eq $i}
$masu
| Set-SCSMObject -Property status -Value $maStatusActive
$cr
| Set-SCSMObject -Property status -Value $crStatus

System Center Universe 2015 Basel

Some impressions and my take aways from the System Center Universe 2015. My focus was on the sessions about automation and Service Manager. In addition I attended to the Power BI Sessions – and they were very exciting.

Keynote: Microsoft Technology outlook with focus on IoT and machine learning (Sascha Corti)
Sascha showed the example, that Microsoft monitors the power consumptions of the  air condition from the Microsoft campus. So they can react much faster, when the consumptions rises. This results in lower downtime and in addition they can safe about 10% of the power consumption.
The second example for IoT was a movie about the london underground – they also monitor “things”. ( see video ).
He also published his actual pulse measured by a Microsoft band on his wrist to a Website as an example for IoT.
It seems that machine learning gets standardized by Microsoft. Sascha showed an example with 30,000 datasets of an survey with standard data (income, education,  age, sex). Machine learning in azure took several minutes and the aim was to predict if the income is over or under 50k. (Link to Azure Machine Learning). And parnters can build Webservices with this learned methods and offer it to customers. Sounds interessting.
A thing that surprised me was, that Microsoft saves money by monitoring the power consumptions of the  air condition from the Microsoft campus. So they can react much faster, when the consumptions rises. This safes them about 10% of power – and money.

System Center Reporting Hero to Super Hero to Earth to Cloud in Warp Speed
Nice and easy Tool, to create analysis templates. Maybe easier than Microsoft Excel  and for an high level view. (PowerBI)

Minimizing Risk in  Modern Powershell Environments with JEA
Nowadays you are only able to make all powershell functions available – or none. So I could give powershell cmdlets to the servicedesk, but then the servicedesk can also destroy my environment. Since I do not like this – they get nothing. With WMF 5.0 (Windows Management Foundation)  JEA (just enough admin) it is possible to define, witch powershell functions are available the the users. Really nice.

Programming SCSM with c# and Visual Studio
Dieter Gasser presented three ways to use visual Studio to enhance the Microsoft Service Manager. One was to enhance the functionality provided by the  Tasks.
Dieter also mentioned, that CIs in Service Manager only make sence, when they are used by Service Requests.

itNetx Produkte
ItnetX gave a look at upcoming products – there are some really nice improvements.
1. A new Service Manager Portal design – the new Portal v3 is with a standard GUI Framework (Bootstrap)
2. Powershell Activities – this extends the Service Manager with a new activity – you can put powershell commands in it, which are executed
3. There will be an update to the Advanced View Editor (AVE). You will be able to create new  views – including calendar views.
4. Admin Tools – with more (easier) security possibilities for admins

Scoosp – starting runbooks as a service via a portal
Another Portal – but this one is for the admins not for the consumers. So there is only the information provides by Sstem Center Orchestrator. It is possible to start runbooks with the parameters. There is no possibility to provide high level business process management processes. But since there are templates for common admin tasks, that could be really useful. (Link to SCOOSP)

How to find out the actual Service Manager version via powershell

It was not that easy to find out the actual Version of our SCSM Installation, since Microsoft does not update the Info Window of Service Manager. So I wrote a powershell line, to find out.

Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{7B523367-360B-4EB6-9ED4-D2637816DD0F}' | Select Displayname, Displayversion, installdate

There is an other way with SQL:

select * from servicemanager.[dbo].[__PatchInfo__] WITH(NOLOCK) order by appliedon desc

Import Excel generated csv to SCSM via powershell

If you want to bulk Import data to System Center Service Manager from CSV with german data using powershell, there two things to do right:

  1. Save the Excel spreadsheet as “CSV (Trennzeichen-getrennt) .csv”
  2. Import into SCSM with right encoding
    1. Import-Csv $Filename -Delimiter ‘;’ -Encoding Default
    2. Import-Csv $Filename -Delimiter ‘;’ -Encoding UTF7

That’s it.

SCSM Templates – Get all Workitems with a specific Title in an Activity

I wanted to find out, which Templates use a manual activity with a specific Value in the Title. This can also be used for other properties.

$findMAmatchTitle = ‘IMPORTANT’
import-module smlets
## get all Workitems at the highest level
get-scsmobjecttemplate | %{$so= $_ ; $_.ObjectCollection} | % {$_.Propertycollection} | ? { $_.mixedvalue -match $findMAmatchTitle } | %{$so}
## get all Activities - be aware no cascades like activities in parallel activities.
get-scsmobjecttemplate | %{$_.ObjectCollection} | % {$_.Propertycollection} | ? { $_.mixedvalue -match $findMAmatchTitle } | %{$_}

If you have activities in activities (eg parallel) you won’t get the second level.

How to find user directories from unauthorized Users

We wanted to clean up our Terminal Servers a little. So we wanted to delete existing user directories from unauthorized users. As a side effect we also got all authorized users never logged in on the server.

# Find User directories on a server (eg Terminal Server) from unauthorized Users (eg deleted Users) and delete them.
# Find authorized Users not logged in yet (authorized users without user directory)
import-module activedirectory
# The directory name has to be equal to the Sam Account Name, the path has to end with ""
$path = "C:Users"
# Subgroups are not supported
$adgroup = <AD group with all authorized Users>
$users = get-adgroupmember $adgroup |select samaccountname
$Users = $Users | add-member -membertype Aliasproperty -Name name -value samaccountname –passthru
$dirs=Get-ChildItem $path | where {$_.Attributes -eq 'Directory'} | select Name
$delme=Compare-object $dirs $users -property name | ? {$_.sideindicator -eq "<="}
$nie = Compare-object $dirs $users -property name | ? {$_.sideindicator -eq "=>"}
#delete them all
foreach ($d in $delme) { $dd = $path + $d.name; rm -r $dd }