Home General Discussion

Configuring a PowerShell Profile for SCSM

Adam_DzyackyAdam_Dzyacky Product Owner Contributor Monkey ✭✭✭✭✭

Of everything I covered in Definitive Service Manager PowerShell, the one thing I didn't address was how useful having a PowerShell profile is.

In short - you use PowerShell to define how PowerShell should start. If you're already using PowerShell profiles, then you know all you have to do is use:

notepad $profile

But if you AREN'T using PowerShell profiles, then you'll need to get one created. Fortunately, that's pretty easy:

New-Item –Path $Profile –Type File –Force

Once created, you can edit it with the original notepad $profile command. Then just CTRL+S or File -> Save, close it and you're done. Now every time you open PowerShell that file just automatically runs. Which is perfect for when you want things just ready to go. Such as load up SMLets to set a bunch of variables for commonly used SCSM Classes, Relationships, Enums, or your own custom Functions.

This also makes remote management of your infrastructure super easy from your local machine. Just update a single variable and boom - connected and ready to run commands whenever you need to.

  • Less typing
  • Less Remote Desktops
  • More doing!
$mgmtServer = "SomeMGMTServer"

$irClass = Get-SCSMClass -name "System.WorkItem.Incident$" -computername $mgmtServer
$scomIRClass = Get-SCSMClass -name "Microsoft.SystemCenter.WorkItem.SCOMIncident$" -computername $mgmtServer
$srClass = Get-SCSMClass -name "System.WorkItem.ServiceRequest$" -computername $mgmtServer
$prClass = Get-SCSMClass -name "System.WorkItem.Problem$" -computername $mgmtServer
$crClass = Get-SCSMClass -name "System.Workitem.ChangeRequest$" -computername $mgmtServer
$rrClass = Get-SCSMClass -name "System.Workitem.ReleaseRecord$" -computername $mgmtServer
$maClass = Get-SCSMClass -name "System.WorkItem.Activity.ManualActivity$" -computername $mgmtServer
$raClass = Get-SCSMClass -name "System.WorkItem.Activity.ReviewActivity$" -computername $mgmtServer
$paClass = Get-SCSMClass -name "System.WorkItem.Activity.ParallelActivity$" -computername $mgmtServer
$saClass = Get-SCSMClass -name "System.WorkItem.Activity.SequentialActivity$" -computername $mgmtServer
$daClass = Get-SCSMClass -name "System.WorkItem.Activity.DependentActivity$" -computername $mgmtServer
$rbClass = Get-SCSMClass -name "Microsoft.SystemCenter.Orchestrator.RunbookAutomationActivity$" -computername $mgmtServer

$compClass = Get-SCSMClass -name "Microsoft.Windows.Computer$" -computername $mgmtServer
$conClass = Get-SCSMClass -name "Cireson.AssetManagement.Consumable$" -computername $mgmtServer
$hwClass = Get-SCSMClass -name "Cireson.AssetManagement.HardwareAsset$" -computername $mgmtServer
$swClass = Get-SCSMClass -name "Cireson.AssetManagement.SoftwareAsset$" -computername $mgmtServer
$poClass = Get-SCSMClass -name "Cireson.AssetManagement.PurchaseOrder$" -computername $mgmtServer
$vendorClass = Get-SCSMClass -name "Cireson.AssetManagement.Vendor$" -computername $mgmtServer
$subnetClass = Get-SCSMClass -name "Cireson.AssetManagement.Subnet$" -computername $mgmtServer
$orgClass = Get-SCSMClass -name "Cireson.AssetManagement.Organization$" -computername $mgmtServer
$costClass = Get-SCSMClass -name "Cireson.AssetManagement.CostCenter$" -computername $mgmtServer

$raHasReviewerRelClass = Get-SCSMRelationshipClass -name "System.ReviewActivityHasReviewer$" -computername $mgmtServer
$raReviewerIsUserRelClass = Get-SCSMRelationshipClass -name "System.ReviewerIsUser$" -computername $mgmtServer
$raVotedByUserRelClass = Get-SCSMRelationshipClass -name "System.ReviewerVotedByUser$" -computername $mgmtServer

$domainUserClass = Get-SCSMClass -name "System.Domain.User$" -computername $mgmtServer
$notificationClass = Get-SCSMClass -name "System.Notification.Endpoint$" -computername $mgmtServer

$irLowImpact = Get-SCSMEnumeration -name "System.WorkItem.TroubleTicket.ImpactEnum.Low$" -computername $mgmtServer
$irLowUrgency = Get-SCSMEnumeration -name "System.WorkItem.TroubleTicket.UrgencyEnum.Low$" -computername $mgmtServer
$irActiveStatus = Get-SCSMEnumeration -name "IncidentStatusEnum.Active$" -computername $mgmtServer

$actStatusPending = Get-SCSMEnumeration -name "ActivityStatusEnum.Ready$" -computername $mgmtServer
$actStatusInProgress = Get-SCSMEnumeration -name "ActivityStatusEnum.Active$" -computername $mgmtServer

$affectedUserRelClass = get-scsmrelationshipclass -name "System.WorkItemAffectedUser$" -computername $mgmtServer
$assignedToUserRelClass  = Get-SCSMRelationshipClass -name "System.WorkItemAssignedToUser$" -computername $mgmtServer
$createdByUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItemCreatedByUser$" -computername $mgmtServer
$workResolvedByUserRelClass = Get-SCSMRelationshipClass -name "System.WorkItem.TroubleTicketResolvedByUser$" -computername $mgmtServer
$wiAboutCIRelClass = Get-SCSMRelationshipClass -name "System.WorkItemAboutConfigItem$" -computername $mgmtServer
$wiRelatesToCIRelClass = Get-SCSMRelationshipClass -name "System.WorkItemRelatesToConfigItem$" -computername $mgmtServer
$wiRelatesToWIRelClass = Get-SCSMRelationshipClass -name "System.WorkItemRelatesToWorkItem$" -computername $mgmtServer
$sysUserHasPrefRelClass = Get-SCSMRelationshipClass -name "System.UserHasPreference$" -computername $mgmtServer
Sign In or Register to comment.