Austrias System Center Blog

The Austrian blog around optimizing datacenters with Microsoft System Center

PowerShell your ServiceManager & ITAM: Get Hardware Maintenance Expiry Information

No Comments »

Hi All !

There are millions of exampled out there to PowerShell your Service Manager and  i dont want to replicate them. So in this Blog Series i will focus on real world examples people have with Service Manager and Provance (2014 Standard or Enterprise).

The first one is about automatic notification of to-be-expired maintenance agreements.

Lets assume you have Provance 2014 and Hardware Maintenance Agreements with a Start  and End Date. Those agreements have related Assets linked to it and contracts managers defined.

You want to get notified periodically about contract expiration and want to know which assets are affected. The timespan  you want to look into the future is configurable and you have the choice to get a HTML Report as a file or an HTML E-Mail send to the agreement manager.

Below is a picture of the idea which agreements are selected.

Powershell your SCSM Blog

Yellow agreements are reported because they are inside the „DueDate“ timeframe

The script will collect those agreement find the linked computer assets and generate a report similar to  the one below.

MaintExpiryExampleReport

Example Report

Ok, now for the magic behind all this.

1.) The scheduler

As this is programmed in Powershell you can use SMA, SCSM Powershell Workflow or Orchestrator to fire it, i decided to use task scheduler on the workflow server. The reasons for this decision are that task scheduler is available on every Windows Server, its free and simple to configure. If you dont wat to use it, simply use yur favorite powershell integration tool.

2.) The script

As announced here it uses native scsm commandlets and the SCSMPX extension from Kirk Munroe. Use it, extend it as you need it and let me know if you find it useful. I think i have put enough comments into the code so you can understand what each part does. If you have questions let me know.

<#.. This script reads Provance Hardware Maintenance agreements, checks if they will expire within the defined
duedays timeframe and writes a HTML report file to disk, containing Agreements and their Assets.
Optionally each agreement Manager will get notified of "his/her" Agreements by E.Mail
..#>
#Parameter Section
Param(
[int32]$DueDays=350,
[string]$ReportFolder="C:\Reports\"
)
# Import-Module $scsmlets
Import-Module scsmpx
#region Definitions
# Define Classes (Object and Relationships)
$C_HWAggr = Get-SCClass -Name "Provance.Class.HardwareMaintenanceAgreement"
$C_HWAsst = Get-SCClass -Name "Provance.Class.ComputerAsset"
$C_User = Get-SCCLass -Name "System.User"
$R_AgHasUser = Get-SCRelationship -Name "Provance.Relationship.AgreementHasUser"
$R_HasMnt = Get-SCRelationship -Name "Provance.Relationship.HardwareAssetStandardHasHardwareMaintenanceAgreement"
# Define List Values and Filters
$Approved = Get-ScsmPxListItem -ListName Provance.Enumeration.AgreementLifeCycle -Name Approved
# Define Agreement Variables
$DueDate = (Get-Date).AddDays($DueDays)
$DueDateString = $DueDate.ToString("dd.MM.yyyy")
$ReportDate = (Get-Date).ToString("dd.MM.yyyy")
$ReportFileName = "ProvanceMainReportDue_$ReportDate.html"
# Set Mail Variables
$SMTPServer = 'mail.yourdomaindomain.local'
$FromAdress = 'ProvanceNotifications@yourdomain.local'
# Stylesheet definition
$Style = @'
<style>
body {Background-color:#EEEEEE; }
body,table,td,th,h1 {font-family:Calibri; color:DarkBlue; Font-Size:14pt; Text-Align:left }
th {font-weight:bold; background-color:#AAAAAA; }
td {background-color:white; }
h1 {font-size:20pt; text-align:left ; color:darkRed}
h2 {font-size;14pt; text-align:left ; color:grey}
</style>
'
@
# Functions
Function Get-SCSMUserEMailAdress ([System.Object]$SCSMUser)
{
$C_userpreference = Get-SCSMRelationship -Id 649e37ab-bf89-8617-94f6-d4d041a05171
$Notif = Get-SCSMRelationshipInstance -SourceInstance $SCSMUser | where {$_.RelationshipId -eq $C_userpreference.Id}
$EmailObject = $Notif.TargetObject.Values | ? {$_.Type -match 'TargetAddress'}
$Email = $EmailObject.Value
$Email
}
<#.. For future Use
$Loc =
$CC =
$Org =
$User =
..#>
#endregion Definitons
#region data processing
# Get the Agreements and the Assets in Variables
$DueAgreements = Get-SCClassInstance -Class $C_HWAggr -Filter "LifeCycle -eq $($Approved.Id)"|?{$_.ExpiryDate -le $duedate}

#Create Data Arrays
$EMailAdresses = @()
$HTMLBody = @()

# Create Base HTML Output File and Header Line
ConvertTo-HTML DisplayName -Head $Style -Precontent "<H1>Hardware Maintenance Expiry report for $DueDateString </H1>"|Out-File "$ReportFolder$ReportFileName"

Foreach ($Agreement in $DueAgreements)
{
# Get the Assets Related to that HWMaint Agreement
$DueAssets = Get-ScsmPxRelatedObject -Target $Agreement -RelationshipClassName $R_HasMnt

# Get The Agreement Manager(s)
$AgreementManagers = Get-ScsmPxRelatedObject -Source $Agreement -RelationshipClassName $R_AgHasUser

# Write Agreement and Related Assets to the Output File
$FileAgreementBody = $Agreement|select-object @{expression={$_.DisplayName};Label="Agreement Name"},ExpiryDate|ConvertTo-Html -Fragment
$FileDueAssetsBody = $DueAssets|select-object @{expression={$_.DisplayName};Label="Asset Name"},AssetTag,Type,SerialNumber,Lifecycle,ReceivedDate|ConvertTo-Html -Fragment

$HTMLBody = $HTMLBody+"<br>"+$FileAgreementBody+"<br>"+$FileDueAssetsBody+"<br><br>"

# Find E-Mail Adresses of Managers in the current agreement
foreach ($AgreementManager in $AgreementManagers)
{ Get-SCSMUserEMailAdress $AgreementManager

# Fill up E-Mail Addresses Array
$EMailAdresses = $EMailAdresses + $EMail
# Send E-Mail to each Agreement Manager
foreach ($EMailAdress in $EMailAdresses)
{
#Create Body Text for One Agreement
$MailBodyStyleHeader = ConvertTo-HTML -Head $Style
$MailBodyTitle = ConvertTo-HTML -Title "Maintenance Due Report for $DueDate"

$AgreementBody = $Agreement | ConvertTo-HTML DisplayName,ExpiryDate -Head $Style
$DueAssetsBody = $DueAssets | ConvertTo-HTML DisplayName,AssetTag,Type,SerialNumber,LifeCycle,ReceivedDate -Fragment

# Summarize Agreement and Asset Data
$MailBody = @($AgreementBody + $DueAssetsBody)

# Send The Mail Message to the AgreementManager
# Send-MailMessage -To $EMailAdress -Subject "Hardware Maintenance Expiry Report for $DuedateString" -SmtpServer $SMTPServer -Encoding UTF8 -From $FromAdress -Body $Mailbody -BodyasHTML
}
}
}
#endregion

# Write Results and Line into the HTML File
$HTMLBody|Out-File "$ReportFolder$ReportFileName" -Append
ConvertTo-HTML $NULL -PostContent "<H2> Report created $ReportDate</H2>" -Fragment |Out-File "$ReportFolder$ReportFileName" -Append

remove-module scsmpx

With best regards /Roman

 

PowerShell your ServiceManager & ITAM: Get Discovered Computer Information

No Comments »

Hi all !

Lets focus on a simple problem, many Service Manager / ITAM customers probably have. A set of discovered computers by AD/SCCM is imported into the ServiceManager CMDB with more or less useful information. On the other hand there is unstructured ITAM data. So what those many people want is:

Create an Asset for every Computer CI in the CMDB !

Even if this is not best ITAM practice, it is a common question/demand, this blog addresses

The solution can be easily done with the ScsmPX Module on GitHub and a little piece of code. In the files available in the download section you will find the Powershell Script, and the Provance Import Template to allow the creation of Assets with Provance DMP.

  1. # This Script reads SCCM discovered computers from the SCSCM database and creates a csv file with the relevant imprt data for Provance ITAM
  2.  
  3. # Load SCSMPX Commandlets
  4. import-module scsmpx
  5.  
  6. # Set Path to store export File
  7. $CSVPath = "C:\transfer\SCCMDiscoveredComputers.csv"
  8.  
  9. # Define classes to retrieve data
  10. $C_WinCmp = Get-SCClass -Name "Microsoft.windows.Computer"
  11. $C_DplCmp = Get-scclass -Name "Microsoft.SystemCenter.ConfigurationManager.DeployedComputer"
  12. $C_User = Get-SCCLass -Name "System.Domain.User"
  13. $R_CompHasPrimUser = Get-SCRelationship -Name "System.ComputerPrimaryUser"
  14.  
  15. # Get Discovered Computer Data
  16. $CmpList = @(Get-SCSMClassInstance -Class $C_WinCmp)
  17.  
  18. # Create empty data array
  19. $CompArr = @()
  20. # Write DiscoveredHardwareData into Array
  21. foreach ($Comp in $CmpList)
  22. {
  23. # Get Hardware Chassis Object
  24. $CompId = $Comp.GetRelatedObjectsWhereTarget($C_DplCmp).EnterpriseManagementObject.Id
  25. # Get Deployed Computer Object
  26. $DplComp = Get-SCClassInstance -Class $C_DplCmp -Filter "Id -eq $CompId" -ErrorAction Ignore
  27. # Get Primary User of the Computer
  28. $PrimUser = Get-ScsmPxRelatedObject -Source $Comp -RelationshipClassName $R_CompHasPrimUser
  29.  
  30. # Put Properties together and write them into PSObject Array
  31. $data = new-object psobject -Property (
  32. [Ordered]@{
  33. ComputerName =$Comp.PrincipalName;
  34. IPAddress =$Comp.IPAddress;
  35. LastInventoryDate =$Comp.LastInventoryDate.ToShortDateString()
  36. HostServerName =$Comp.HostServerName;
  37. IsVirtualMachine =$Comp.IsVirtualMachine;
  38. VirtualMachineName =$Comp.VirtualMachineName;
  39. SerialNumber =$DplComp.SerialNumber;
  40. SMBIOSAssetTag =$DplComp.SMBIOSAssetTag;
  41. Manufacturer =$DplComp.Manufacturer;
  42. Model =$DplComp.Model;
  43. PrimaryUserName =$PrimUser.UserName;
  44. PrimaryUserDN =$PrimUser.DisplayName;
  45. }
  46. ) -ErrorAction SilentlyContinue
  47. $CompArr += $data
  48.  
  49. Start-Sleep -Milliseconds 50
  50.  
  51. }
  52. #Create Import CSV File
  53. $CompArr | select -property * | export-csv $CSVPath -Encoding UTF8 -NoTypeInformation
  54.  
  55. # Unload Modules
  56. Remove-Module scsmpx

The Import Template uses this CSV and loads the Data as Assets, depending on if its physical Computers or virtual machines. Below find a screenshot of the template:

Import-Template

Screenshot of the Import Template (Provance Data Management)

Finally if you load the data with the Provance DMP you get:

  • Physical Hardware Assets + Assigned User
  • Hardware Catalog Items for Physical Computers + related Vendor
  • Virtual Computer Assets + Assigned Users
  • All assets are linked to CI´s

Way to go and start importing/editing financial data for your assets

Update: Sept 2015: Script now uses Powershell v3 PSObject way of creating arrays

Cheers / Roman

Script and Import Template

PowerShell your ServiceManager & ITAM: Intro

No Comments »

Dear All !

Service Manager has a wide range of customers and many people deploy or use it in operations. All those know that Service Manager needs customization and sometimes also development to fulfill the needs of IT organizations.

This blog is the starting point of a series to manage Service Manager with Powershell.

BORING you might be forced to say – but wait – this series differs from all those tons of other blogs out in the wild by a couple of facts i will explain now.

  1. No SMLets – SMLets are still in Beta and the future is unclear
  2. Leverage ScsmPX Modules. Kirk Munroes´s (the Poshoholic :-))  ScsmPX Module is Open Source, is based on Microsofts SCSM-native Modules and extends them with the functions that are missing.
  3. No SMA, Orchestrator, or other SC products just native PowerShell. We know you can call anything from anywhere so automation is  limitless (SMA,SCOR,SCSM, …) but we want to focus on the basics.
  4. Examples will be based on Service Manager and Provance 2014 ITAM, from what i saw in the field but the examples are open so you will be able to adapt them to your needs.

The first entry will be posted soon, so stay tuned.

R.

Links:

https://kirkmunro.github.io/ScsmPx/

Update #1: I have attached a screenshot sample in PDF of „How to runa powershell script with parameters with task manager“ because the exampled following are based on that and so you have a easy reference for configuring Task Scheduler.

Run a Powershell Script with Paramaters with task Scheduler

Provance announces „The Suite“

No Comments »

Hi All !

2 days ago Provance announced a bundle of software products for
System Center Service Manager. Included will be i.e.

  • Syliances Portal
  • Gridpro´s Web Console
  • Expits Analytics

and a bunch of other stuff, making Service Manager customers life easier.

More info at the www.systemcentersolutionstore.com or the original press release

http://www.provance.com/itam-university/news/postid/120/new-low-priced-suite-enhancements-microsoft-system-center-scsm-now-available

Cheers / Roman

 

SCSM: Print Service Request Task

No Comments »

Hi All !

Ever tried to print a WorkItem ? Well i recommend – dont do that – because
what you get is a print of all properties from all tabs, without the selection method
to limit the outcome which might lead to a 6 or more page print.

A customer asked for a possibility to print selective data from a Service Request on one
because page because sometimes the field support has to have something printed.

The solution below consists of a PowerShell script which collects the infomation you want
and prints this within a nice HTML-based layout of your choice.

An output might look like this:

SRPrintOutput

All you need is:

  • The standard SCSM commandlets installed with the SCSM-Console
  • Winword or your favorite HTML-Editor
  • The Powershell script attached.
  • A new task in SCSM

So how does it work ?

1.) Select which properties you want to show in the HTML Form.

This might be the Title, ID, Status and so on. The properties must be written inside
the HTML-form as placeholders for the data.

Furthermore, the properties must be placed into variables in the Powershell script

 2.) Generate the HTML-Template

Open Winword, design your page with tables, fonts, … and place the variables inside
the template as shown in the screenshot below.

SRHTMLTemplate

 3.) Save as „Website -filtered“

Saveasfiltered

 4.) Paste the HTML Code in the Powershell script

In the Powershell Schript SRPrint.ps1 you find a section called:

$header = @“PLACE FOR HTML CODE„@

Replace the grey text with the HTML Code from the Winword file which will look like this:

HTMLInPowershell

5.) Create a task

In Service Manager – Library – Create a Task with no categories and the following parameters

The Powershell-script of the task needs one parameter -SRIdent which is the SR-ID. This
parameter is then handed over by SCSM to identify the Service Request.

Many thanks to Christian Graf from Asterios Design which lead me to the right direction on
howto call HTML from Powershell.

See the Powershell Script here.

Cheers / Roman

Create CSV out of Powershell Data

No Comments »

Hi All !

Recently i had the situation, where there was no SCCM Agent in an environement for specific
reasons, but the customer wanted to use this data to fill up his SCSM Database (Provance Assets in that case). So we had more ore less empty CI´s in the SCSM Database and wanted to fill this up with directly scanned WMI Data.

The result should have a format to be directly used by an SCSM Import Tool.

The Powershell Script queries all Virtual machines in the SCSM Database and gets information from online machines via WMI. This data is then written to a CSV File. Use and have fun.

 # Script to query Online Virtual Machines based on SCSM Data to get Serial Numbers
import-module smlets
$Computers = Get-SCSMCLass Microsoft.windows.Computer$
$VMList = @(Get-SCSMObject $Computers -Filter „IsVirtualMachine -eq ‚true'“)
$Arr = @()
foreach ($VM in $VMList)
    {
        $data = new-object psobject # New Object
        $data | add-member -membertype NoteProperty -Name ComputerName -Value $VM.NetBiosComputerName
        $data | add-Member -membertype NoteProperty -Name SerialNumber -Value (Get-WMIObject -Class „Win32_BIOS“ -Computername $VM.NetBiosComputerName).SerialNumber
        $data | add-Member -membertype NoteProperty -Name OSName -Value (Get-WMIObject -Class „Win32_OperatingSystem“ -Computername $VM.NetBiosComputerName).Caption
        $data | add-Member -membertype NoteProperty -Name Manufacturer -Value (Get-WMIObject -Class „Win32_ComputerSystem“ -Computername $VM.NetBiosComputerName).Manufacturer
        $data | add-Member -membertype NoteProperty -Name Model -Value (Get-WMIObject -Class „Win32_ComputerSystem“ -Computername $VM.NetBiosComputerName).Model
        $Arr += $data
     }
$arr | select -property ComputerName,SerialNumber,OSName,Manufacturer,Model | export-csv -notypeinformation .\Documents\VMSerials.csv
Remove-Module Smlets

The result is a CSV file like this.

„ComputerName“,“SerialNumber“,“OSName“,“Manufacturer“,“Model“
„Server1″,“1111-1111-1111-5431-2407-9700-21″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
„Server2″,“2222-2222-2222-7060-4845-5504-27″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
„Serern“,“3333-3333-3333-9977-7669-1954-03″,“Microsoft Windows Server 2012 R2 Standard“,“Microsoft Corporation“,“Virtual Machine“
 

Regards / Roman

 

Map Assets to locations with on-board facilities

No Comments »

Dear All !

Recently a customer asked me if it is possible to map assets to locations based on their IP address.
Even if this is more of a configuration management issue than asset management, i wanted to know
how easy that is with on-board functionality of Service Manager, Provance and Orchestrator.

See the results in the video which contains the scenario, the demo and the explanation of the solution.

Location-Assets

==> YOUTUBE VIDEO ==> Click on the Link for the video.

If you want to try the solution – please see the attached files here IP2LocationMapping
They contain the slideshow, the class extension -XML and the Orchestrator runbook.

Cheers / Roman

Provance ITAM Integration with SAP

No Comments »

Hi all !

A question / demand of customers which comes very often is how to integrate Asset Management with ERP. In this demo
i am going to show you how this can be done with the help of SystemCenter Tools and Provance Software.

SAPProvanceExampleScrSh

You will first see a Powerpoint with the scenarios i created for the demo and then the actual implementation.

==> YOUTUBE VIDEO ==> Click on the Link for the video.

What you need to implement this is:

  • System Center Service Manager 2012 SP1
  • System Center Orchestrator 2012 SP1
  • Provance Asset management Pack
  • Provance Data Management Pack
  • Provance Support Powershell Module (Ask Provance)
  • Orchestrator Powershell Integration Pack 1.2 http://gallery.technet.microsoft.com/Orchestrator-Integration-438f9ece
  • good process definitions because automation needs a high level of standardization

Technical Implementation

1.) Installation of the Provance Support Modules

Contact support@provance.com to get the the latest support-modules. This are 2 Files, ProvanceSupport and ScsmLoader.
Extract them to a folder within the PSModulePath Environement Variable.
A Powershell session should (if correctly installed) allow you to load

import-Module ScsmLoader
import-Module ProvanceSupport

After that the „Import-ProvanceData“ command should be available.

2.) Preperation of the first SCSM Management Server (Workflow Server)

On the Workflow Server there has to be one account which is allowed to import DMP Data, this account will be used by the
remote Powershell Session to start the DMP Import. So before playing around with Orchestrator log in with that account
and try to import data with the DMP via Powershell.

The account you are using must have started the SCSM Console successfully once, bcs. the import-provancedata command
uses the registry entries to connect to the manegement server.

 3.) Preperation of Orchestrator.

Have Orchestrator 2012 SP1 (i am running R2) installed, the Service Manager 2012 OIP installed and configured
and the Powershell Extension 1.2 installed and configured.

Execute_PSScript

The Powershell execution activity needs to be configured that way.

ProvanceDMPProperties

Enter a the Workflow Server as the hostname, domain, username and password of the account you have been
configuring for the DMP Import.

The command in „PS Script 01“ is:

Powershell {Import-ProvanceData -DMPTemplateName TemplateName -CsvPath "DataBusData" -verbose} 2>&1

All the other technical implementation details are shown in the video. Attached to this BlogEntry you find:

  1. Runbook example on how to start DMP Import from Orchestrator (DMPImportExample.ois_export)
  2. Runbook example for a purchase order export (WritePOFile.ois_export)
  3. DMP Templates and example files ImportTemplatesandFiles.zip

I hope you have found that useful, if you have questions, at the very beginning of the video you find my E-Mail Adress.

Best regards / Roman

ProvanceSAPFiles

Provance Chargeback Solution with 11 kb of Code – Part #1

No Comments »

Hi All !

In many discussions with Provance partners and customers, there is always the question for charging the customers for IT Services/Products/Assets.
Therefor i have put together this video and the according files and links to make this real for everybody and get reports like the one below.

HWCB-Screenshot

There are 2 videos, the first one will show the solution design and the perspective of the ITAM-Manager, the second part, shows the technical side with Management Packs, Data Warehouse and SSRS Configuration.

Have fun !

Roman

Link to video#1

Link to video#2

Below you will find the needed files to implement the solution.

ManagementPacks

ReportDefinition

 

Provance Reporting #1: Custom Hardware Asset Report

No Comments »

Hello All !

Thanks to the great consultant Christoph Aichinger from Antares Netlogix, who is the mastermind behind this work, this video and the attached file will show you how to create a custom report in System Center Servier Manager and the Provance IT Asset Management Pack.

Please watch the video and use the downloaded RDL-File to test this in your environement.

Have fun !

http://youtu.be/mLeptjiePRQ

Custom Asset Report

Roman