项目作者: KirkMunro

项目描述 :
System Center Service Manager PowerShell Extensions
高级语言: PowerShell
项目地址: git://github.com/KirkMunro/ScsmPx.git
创建时间: 2014-03-21T01:35:40Z
项目社区:https://github.com/KirkMunro/ScsmPx

开源协议:Apache License 2.0

下载


ScsmPx

Overview

The ScsmPx module facilitates automation with Microsoft System Center Service
Manager by auto-loading the native modules that are included as part of that
product and enabling automatic discovery of the commands that are contained
within the native modules. It also includes dozens of complementary commands
that are not available out of the box to allow you to do much more with your
PowerShell automation efforts using the platform.

Minimum requirements

  • PowerShell 3.0
  • SnippetPx module

Copyright 2016 Provance Technologies

Licensed under the Apache License, Version 2.0 (the “License”);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

  1. http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an “AS IS” BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Installing the ScsmPx module

ScsmPx is dependent on the SnippetPx module. You can download and install the
latest versions of ScsmPx and SnippetPx using any of the following methods:

PowerShellGet

If you don’t know what PowerShellGet is, it’s the way of the future for PowerShell
package management. If you’re curious to find out more, you should read this:
Package Management for PowerShell Modules with PowerShellGet

Note that these commands require that you have the PowerShellGet module installed
on the system where they are invoked.

  1. # If you don’t have ScsmPx installed already and you want to install it for all
  2. # all users (recommended, requires elevation)
  3. Install-Module ScsmPx,SnippetPx
  4. # If you don't have ScsmPx installed already and you want to install it for the
  5. # current user only
  6. Install-Module ScsmPx,SnippetPx -Scope CurrentUser
  7. # If you have ScsmPx installed and you want to update it
  8. Update-Module

PowerShell 3.0 or Later

To install from PowerShell 3.0 or later, open a native PowerShell console (not ISE,
unless you want it to take longer), and invoke one of the following commands:

  1. # If you want to install ScsmPx for all users or update a version already installed
  2. # (recommended, requires elevation for new install for all users)
  3. & ([scriptblock]::Create((iwr -uri http://tinyurl.com/Install-GitHubHostedModule).Content)) -ModuleName ScsmPx,SnippetPx
  4. # If you want to install ScsmPx for the current user
  5. & ([scriptblock]::Create((iwr -uri http://tinyurl.com/Install-GitHubHostedModule).Content)) -ModuleName ScsmPx,SnippetPx -Scope CurrentUser

ScsmPx, the native SCSM cmdlets, and SMLets

The ScsmPx module was designed to address some of the challenges presented
by other Microsoft Windows PowerShell modules that were intended to
facilitate automation tasks with Microsoft System Center Service Manager.

Starting with the 2012 release, Microsoft System Center Service Manager has
included two Microsoft Windows PowerShell modules in its installation
package. These modules are installed automatically on every management
server and every management console. There are 116 cmdlets included in these
two modules to provide automation support to Microsoft System Center Service
Manager 2012 and later. Unfortunately, these modules are not installed
according to Microsoft Windows PowerShell best practices, and as a result
they are not easily loaded or used outside of the Microsoft Windows
PowerShell session that is opened through the management console. This makes
automation of the Microsoft System Center Service Manager platform much more
difficult than it should be. Discovery and loading issues aside, there are
also some design issues that make working with the commands in the native
modules more difficult than it should be. Add to that some gaps in the
coverage provided by the native modules and you end up with a lackluster
user experience.

Prior to the Microsoft System Center Service Manager 2012 release, several
Microsoft employees and some members of the community collaborated on an
open-source project called SMLets. SMLets is a Microsoft Windows PowerShell
module hosted on CodePlex that defines 97 cmdlets to provide automation
support to Microsoft System Center Service Manager 2010 and later. While the
SMLets module has been a very useful resource for Microsoft System Center
Service Manager 2010, with the 2012 release its usefulness has diminished
rapidly for a number of reasons.

First, and most importantly, the SMLets module is not compatible with the
native modules that ship with Microsoft System Center Service Manager 2012.
It may appear compatible, but only if you load it after the native modules
have been loaded. In this scenario, it is swallowing an error and hiding the
incompatibility from the end user. If you load SMLets first, the native
System.Center.Service.Manager module will not load at all due to the
incompatibility.

Second, since Microsoft now includes native modules out of the box, it is
likely that any future investment in automation capabilities for Microsoft
System Center Service Manager will be made there. The SMLets module has
not been updated since March 2012 (almost 2 years at the time of this
writing).

Finally, there are many commands that are duplicated between the SMLets and
the native cmdlets that ship with Microsoft System Center Service Manager.
These duplications are unnecessary, and between duplicated cmdlets with
different parameters, incompatibility issues, error masking, and a lack of
an update it seems that SMLets are best left to automation tasks with the
downlevel Microsoft System Center Service Manager 2010 release.

ScsmPx is a module that tries to bring together the best of both of these
solutions while addressing the biggest issues that each one has created. For
the native Microsoft System Center Service Manager modules, ScsmPx makes the
cmdlets they contain discoverable which enables auto-loading support for
those modules so that they can be used from any Microsoft Windows PowerShell
host more easily. For the SMLets incompatibility and overlap issues, the
ScsmPx module provides 119 additional commands (open-source functions that
are written in Microsoft Windows PowerShell script) to attempt to close the
functionality gap so that SMLets are not required anymore. By offering a
complementary solution instead of a conflicting one, ScsmPx gives you a
single module to start from when working out automation solutions for
Microsoft System Center Service Manager 2012 and later releases.

Note that while ScsmPx adds many valuable commands today, it does not yet
cover all of the capabilities provided by the SMLets module. Over time
more commands will be added to provide this additional coverage.

How to load the module

To load the ScsmPx module into PowerShell, invoke the following command:

  1. Import-Module -Name ScsmPx

This command is not necessary if you are running Microsoft Windows
PowerShell 3.0 or later and if module auto-loading is enabled (default).
The presence of this module also enables auto-loading of the native modules
that ship with Microsoft System Center Service Manager 2012 and later.

ScsmPx Commands

There are 148 commands available in the ScsmPx module today, and 116 cmdlets
in the native modules, offering a total of 264 commands to make Microsoft
System Center Service Manager automation easier. To see a list of all of the
commands that are available in the ScsmPx and native modules, invoke the
following commands:

  1. Get-SCSMCommand
  2. Get-ScsmPxCommand

The first command will return a list of commands that are included in the
native modules that ship with Microsoft System Center Service Manager. The
second command will return a list of commands that are included in the
ScsmPx module. Note that all ScsmPx module commands start with the ScsmPx
noun prefix.

Managing Microsoft System Center Service Manager with ScsmPx

To see a list of all incidents that you have in your environment, invoke
the following command:

  1. Get-ScsmPxIncident

This data represents individual instances of the System.WorkItem.Incident
class, and it does not identify any of the objects that are related to those
instances. Commands invoked like this allow for very efficient management of
Microsoft System Center Service Manager object data. If you want to work
with more complex data that includes multiple related instances combined
into a single view, you can request a specific view of that data instead by
using the -View parameter. For example, to see a more user friendly view of
the incidents in your environment you could invoke the following command
instead:

  1. Get-ScsmPxIncident -View All

This data provides the same information that you see when you access the
corresponding “All Incidents” view in the management console. Note that you
cannot apply filters when you are looking up data using a view. In those
cases, the filters that are defined as part of the view are used.

To see what you can do with that data once you have it, have a look at the
other ScsmPxIncident commands by invoking the following command:

  1. Get-Command -Noun ScsmPxIncident

This identifies that there are other commands that work with incidents. To
use these commands to modify incidents, you can leverage the pipeline. For
example, to automatically resolve any incidents that have been closed for
more than 7 days, you could use the Set-ScsmPxIncident command in the
following script:

  1. # Look up the Resolved incident status enumeration
  2. $resolved = Get-ScsmPxListItem -ListName IncidentStatusEnum -Name Resolved
  3. # Look up the Closed incident status enumeration
  4. $closed = Get-ScsmPxListItem -ListName IncidentStatusEnum -Name Closed
  5. # Identify our search filters (closed incidents at least 7 days old)
  6. $filters = @(
  7. "(Status -eq '$($closed.Id)')"
  8. "(LastModified -lt '$((Get-Date).AddDays(-7))')"
  9. )
  10. # Now get any matching incidents and change their status to resolved
  11. Get-ScsmPxIncident -Filter ($filters -join ' -and ') |
  12. Set-ScsmPxIncident -Property @{Status = $resolved}

That demonstrates one simple example to a common problem that these commands
can help resolve with little effort. Between PowerShell scripts, PowerShell
workflows, Microsoft System Center Service Manager workflows, Microsoft
System Center Orchestrator workflows, and now the new Service Management
Automation (SMA) feature of Microsoft System Center Orchestrator, there are
plenty of opportunities to use PowerShell commands to automate Microsoft
System Center Service Manager. Experiment with the other commands in the
ScsmPx module and see what solutions you can come up with.

Command List

The ScsmPx module currently includes the following commands:

  1. Get-ScsmPxAdGroup
  2. Get-ScsmPxAdPrinter
  3. Get-ScsmPxAdUser
  4. Get-ScsmPxBuild
  5. Get-ScsmPxBusinessService
  6. Get-ScsmPxChangeRequest
  7. Get-ScsmPxCommand
  8. Get-ScsmPxConfigItem
  9. Get-ScsmPxConnectedUser
  10. Get-ScsmPxDependentActivity
  11. Get-ScsmPxDwCube
  12. Get-ScsmPxDwDataSource
  13. Get-ScsmPxDwName
  14. Get-ScsmPxEnterpriseManagementGroup
  15. Get-ScsmPxEnvironment
  16. Get-ScsmPxIncident
  17. Get-ScsmPxList
  18. Get-ScsmPxListItem
  19. Get-ScsmPxKnowledgeArticle
  20. Get-ScsmPxManagementServer
  21. Get-ScsmPxManualActivity
  22. Get-ScsmPxObject
  23. Get-ScsmPxParallelActivity
  24. Get-ScsmPxPrimaryManagementServer
  25. Get-ScsmPxProblem
  26. Get-ScsmPxRelatedObject
  27. Get-ScsmPxReleaseRecord
  28. Get-ScsmPxRequestOffering
  29. Get-ScsmPxReviewActivity
  30. Get-ScsmPxRunbook
  31. Get-ScsmPxRunbookActivity
  32. Get-ScsmPxSequentialActivity
  33. Get-ScsmPxServiceOffering
  34. Get-ScsmPxServiceRequest
  35. Get-ScsmPxSoftwareItem
  36. Get-ScsmPxSoftwareUpdate
  37. Get-ScsmPxUserOrGroup
  38. Get-ScsmPxViewData
  39. Get-ScsmPxWindowsComputer
  40. New-ScsmPxObject
  41. New-ScsmPxObjectSearchCriteria
  42. New-ScsmPxProxyFunctionDefinition
  43. Remove-ScsmPxAdGroup
  44. Remove-ScsmPxAdPrinter
  45. Remove-ScsmPxAdUser
  46. Remove-ScsmPxBuild
  47. Remove-ScsmPxBusinessService
  48. Remove-ScsmPxChangeRequest
  49. Remove-ScsmPxConfigItem
  50. Remove-ScsmPxDependentActivity
  51. Remove-ScsmPxDwCube
  52. Remove-ScsmPxDwDataSource
  53. Remove-ScsmPxEnvironment
  54. Remove-ScsmPxIncident
  55. Remove-ScsmPxKnowledgeArticle
  56. Remove-ScsmPxManagementServer
  57. Remove-ScsmPxManualActivity
  58. Remove-ScsmPxObject
  59. Remove-ScsmPxParallelActivity
  60. Remove-ScsmPxProblem
  61. Remove-ScsmPxReleaseRecord
  62. Remove-ScsmPxRequestOffering
  63. Remove-ScsmPxReviewActivity
  64. Remove-ScsmPxRunbook
  65. Remove-ScsmPxRunbookActivity
  66. Remove-ScsmPxSequentialActivity
  67. Remove-ScsmPxServiceOffering
  68. Remove-ScsmPxServiceRequest
  69. Remove-ScsmPxSoftwareItem
  70. Remove-ScsmPxSoftwareUpdate
  71. Remove-ScsmPxUserOrGroup
  72. Remove-ScsmPxWindowsComputer
  73. Rename-ScsmPxAdGroup
  74. Rename-ScsmPxAdPrinter
  75. Rename-ScsmPxAdUser
  76. Rename-ScsmPxBuild
  77. Rename-ScsmPxBusinessService
  78. Rename-ScsmPxChangeRequest
  79. Rename-ScsmPxConfigItem
  80. Rename-ScsmPxDependentActivity
  81. Rename-ScsmPxDwCube
  82. Rename-ScsmPxDwDataSource
  83. Rename-ScsmPxEnvironment
  84. Rename-ScsmPxIncident
  85. Rename-ScsmPxKnowledgeArticle
  86. Rename-ScsmPxManagementServer
  87. Rename-ScsmPxManualActivity
  88. Rename-ScsmPxObject
  89. Rename-ScsmPxParallelActivity
  90. Rename-ScsmPxProblem
  91. Rename-ScsmPxReleaseRecord
  92. Rename-ScsmPxRequestOffering
  93. Rename-ScsmPxReviewActivity
  94. Rename-ScsmPxRunbook
  95. Rename-ScsmPxRunbookActivity
  96. Rename-ScsmPxSequentialActivity
  97. Rename-ScsmPxServiceOffering
  98. Rename-ScsmPxServiceRequest
  99. Rename-ScsmPxSoftwareItem
  100. Rename-ScsmPxSoftwareUpdate
  101. Rename-ScsmPxUserOrGroup
  102. Rename-ScsmPxWindowsComputer
  103. Reset-ScsmPxCommandCache
  104. Restore-ScsmPxAdGroup
  105. Restore-ScsmPxAdPrinter
  106. Restore-ScsmPxAdUser
  107. Restore-ScsmPxBuild
  108. Restore-ScsmPxBusinessService
  109. Restore-ScsmPxConfigItem
  110. Restore-ScsmPxEnvironment
  111. Restore-ScsmPxKnowledgeArticle
  112. Restore-ScsmPxManagementServer
  113. Restore-ScsmPxObject
  114. Restore-ScsmPxServiceRequest
  115. Restore-ScsmPxSoftwareItem
  116. Restore-ScsmPxSoftwareUpdate
  117. Restore-ScsmPxUserOrGroup
  118. Restore-ScsmPxWindowsComputer
  119. Set-ScsmPxAdGroup
  120. Set-ScsmPxAdPrinter
  121. Set-ScsmPxAdUser
  122. Set-ScsmPxBuild
  123. Set-ScsmPxBusinessService
  124. Set-ScsmPxChangeRequest
  125. Set-ScsmPxConfigItem
  126. Set-ScsmPxDependentActivity
  127. Set-ScsmPxDwCube
  128. Set-ScsmPxDwDataSource
  129. Set-ScsmPxEnvironment
  130. Set-ScsmPxIncident
  131. Set-ScsmPxKnowledgeArticle
  132. Set-ScsmPxManagementServer
  133. Set-ScsmPxManualActivity
  134. Set-ScsmPxObject
  135. Set-ScsmPxParallelActivity
  136. Set-ScsmPxProblem
  137. Set-ScsmPxReleaseRecord
  138. Set-ScsmPxRequestOffering
  139. Set-ScsmPxReviewActivity
  140. Set-ScsmPxRunbook
  141. Set-ScsmPxRunbookActivity
  142. Set-ScsmPxSequentialActivity
  143. Set-ScsmPxServiceOffering
  144. Set-ScsmPxServiceRequest
  145. Set-ScsmPxSoftwareItem
  146. Set-ScsmPxSoftwareUpdate
  147. Set-ScsmPxUserOrGroup
  148. Set-ScsmPxWindowsComputer