Quantcast
Channel: SCSM PowerShell Cmdlets
Viewing all 306 articles
Browse latest View live

New Post: Using SMLETS to assign an incident to a user

$
0
0

I have been trying to do this for quite some time. I have already created an incident and filled in all of the fields with the appropriate information. All I need to do now is have that incident assigned to one of our people. I can only assign it by the name as I am not an administrator and do not have access to things such as templates or higher functions. I do have the System Center Service Manager console where I can create, edit, and assign tickets to myself or others. I feel that SMLETS should have this functionality as it seems rather rudimentary.


In the end I want to create a new incident with New-SCSMIncident (which I have already done) and assign it to myself (using DOMAIN\Username as that already works) so that it is ready for me later in my queue.

Is this possible in any way, shape, or form?


New Post: Add private comment to an incident

$
0
0

Hello,

is there a way to add a private analyst comment to an incident by using SMlets?

I tried the following command but the attribute "private" has null value after the execution: 

Set-SCSMIncident -ID <ID> -Comment <Comment> 

Thank you for your help.

regards,

Marco

New Post: Possible to export attachments via SMlets?

$
0
0

Hi all,

I'm looking for a way to export attachments from existing incidents in SCSM 2012.

Is there an option doing this with SMlets?

Have tried to go through (get-scsmincident -id IRXX).fileattachment | fl to find the "content" but it seems to be more complex than this... :)

 

Any help is very appreciated.

Thanks

Alex

New Post: Possible to export attachments via SMlets?

New Post: Update Owner for Windows Computer

$
0
0

we have an owner field that pulls from AD,  is there a way to update the owner of a Windows Computer with set-scsmobject?

 

Thanks

Commented Issue: Issues invoking SMlets from a remote machine [10188]

$
0
0
I have SCSM installed in a lab, on a member server. I'm on a laptop that sits outside the domain. I have SMlets installed there too, as well as the authoring toolkit and the SCSM console.

When I try to load the SMlets, the first time I was getting errors because they couldn't find the SDK Binaries folder in the SCSM install folder. These do not seem to be installed with the authoring toolkit nor with the SCSM console. I had to copy them over from the server. It would be useful if the SMlets checked for this and reported an appropriate error, telling users what to do.

Next, once they were loaded, I can invoke them with simple calls, such as Get-SCSMIncident. When I do that however, since SCSM isn't installed locally, I get an unhelpful error:

Get-SCSMIncident : The Data Access service is either not running or not yet initialized. Check the event log for more i
nformation.
At line:1 char:17
+ get-scsmincident <<<<
+ CategoryInfo : InvalidOperation: (localhost:String) [Get-SCSMIncident], ServiceNotRunningException
+ FullyQualifiedErrorId : GenericMessage,SMLets.SCSMIncidentGet

This should be designed better so that the cmdlets check to see if SCSM is installed on the local machine if they're run locally (it could check once and cache it, because it does the check on import), and then if you invoke a local command by accident it should tell you SCSM isn't installed on the local machine.

Also, it would be quite useful to add a Connect-SCSMServer cmdlet, where I could specify the server name and the credentials, and then from that point on every other SMLet I would call would use that connection. That would be much, much easier for remote management of SCSM.
Comments: ** Comment from web user: smithbj **

Try running the script below prior to any cmlets. It should use the computer specified in all scripts you run in that session.

$smdefaultcomputer = 'smserver.domain.local'

New Post: Retrieve End-User and Analyst comments for an incident

$
0
0

Hi all,

 

is there a way to query the End-User and Analyst comments created in a particular incident by using the PowerShell SMlets?

I've noticed there's a way to create new Analyst comments by using the "set-scsmincident -comment" cmdlet but I couldn't find a way to retrieve them back. Apparently the comment switch does not exist for the get-scsmincident cmdlet?!

 

Any help is very appreciated!

Thanks

Alex 

New Post: get-scsmobject

$
0
0

I am creating a test/dev environment for SCSM 2012 and only wanted to bring in a subset of users through the AD Connector.  Unfortunately I pulled in 230,000 users and it has overwhelmed my test box. 

I've deleted the connector and now I'm trying to remove the users via Powershell. I found this link:

http://smlets.codeplex.com/discussions/223385

and it provides this command:

get-scsmobject Microsoft.AD.User$ -Filter "Firstname -eq 'Phil'" | remove-scsmobject -whatif

which seems to be exactly what i want to do. Unfortunately I'm getting this error:

Get-SCSMObject : Cannot bind parameter 'Id'. Cannot convert value "Microsoft.AD.User$" to type "System.Guid". Error: "G
uid should contain 32 digits with 4 dashes (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)."
At line:1 char:15
+ get-scsmobject <<<<  Microsoft.AD.User$ -Filter "Firstname -eq 'Phil'" | remove-scsmobject -whatif
    + CategoryInfo          : InvalidArgument: (:) [Get-SCSMObject], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,SMLets.GetSMObjectCommand


I'm pretty new to powershell so any help would be appreciated.
Thanks.

New Post: Retrieve End-User and Analyst comments for an incident

$
0
0

Have sorted this now. If anyone is interested below is the code I wrote to get the comments and extract them with some additional data into a CSV like file.

You need to change the classes and filter criteria of course if you want to re-use this script. AppliesTotroubleTicket is basically the attribute which stores the action log + comments so that's what you need to query via PowerShell.

 

Import-Module SMlets -CMDlet get-scsmclass,get-scsmobject,get-scsmincident

$AllComments = ""
$IncidentDefInfos = ""
$Incident = ""
$Comment = ""
$IncidentsID = ""
$AllCommentsResults = ""

$incidentextension = get-scsmclass -name ClassExtension_4b8fb113_d448_4757_8a3c_28b7e37e5111;
$IncidentsID = get-scsmobject -class $incidentextension | where {$_.BusinessApplication -ne $NULL -AND $_.Status -ne "Resolved"} | select ID

foreach ($Incident in $IncidentsID)
{
    $IncidentDefInfos = get-scsmincident -ID $Incident.ID
    $FilteredIncidents = $IncidentDefInfos.AppliesToTroubleTicket | where {$_.ClassName -eq "System.WorkItem.TroubleTicket.UserCommentLog" -OR $_.ClassName -eq "System.WorkItem.TroubleTicket.AnalystCommentLog"}   
    if ($FilteredIncidents.count -gt 0)
    {
        foreach ($Comment in $FilteredIncidents)
        {
            $UserComment = ""
            $AnalystComment = ""
            $ClassName = ""
            $ClassName = $Comment | select ClassName
            Switch($ClassName.ClassName)
            {
                "System.WorkItem.TroubleTicket.UserCommentLog" {$UserComment = $Comment | select EnteredDate, EnteredBy, Comment}
                "System.WorkItem.TroubleTicket.AnalystCommentLog" {$AnalystComment = $Comment | select EnteredDate, EnteredBy, Comment, IsPrivate}
            }
         $IncidentComments = $Incident.ID + '","' + $UserComment.EnteredDate + '","' + $UserComment.EnteredBy + '","' + $UserComment.Comment + '","' + $AnalystComment.EnteredDate + '","' + $AnalystComment.EnteredBy + '","' + $AnalystComment.Comment + '",' + $AnalystComment.IsPrivate + "`r`n"
         $AllIncidentComments += $IncidentComments
        }
    }
}

write-host $AllIncidentComments
Out-File  -InputObject $AllIncidentComments -FilePath C:\Software\AllComments.csv

Remove-Module SMlets

PS: Can anyone point me out how to use the -Filter switch correctly if you need to filter on two attributes? I'd like to get rid of the 'where' filtering to optimize the script performance.


Cheers

Alex

New Post: get-scsmobject

$
0
0

Hi mate,

try this one:

$UserClass = get-scsmclass -Name Microsoft.AD.User$
get-scsmobject -class $UserClass -Filter "Firstname -eq 'Phil'" | remove-scsmobject -whatif

Regards

Alex

New Post: Add-SCSMEnumeration

$
0
0

I am attempting to use the Add-SCSMEnumeration command to add a value to an existing list. In crawling the web to find the best way to do this I have come up with the following. I am still unable to get this to work... Any guidance would be GREATLY appreciated in getting this to work. My command and error are shown below.

-----------------------------------------------------------------------------------------------------------------------------------------

PS C:\Users\admin_ryan> Add-SCSMEnumeration -Parent (Get-SCSMEnumeration -Id "66b02881-ba7a-00ee-8859-b3a6fc8d4a24") -Ma
nagementPackName WNB_CustomMP_IncidentExtensionLists -DisplayName "TestRegion1Add" -Name TestRegion1Add.Enum -Ordinal 80
0
Add-SCSMEnumeration : Value cannot be null.
Parameter name: input
At line:1 char:20
+ Add-SCSMEnumeration <<<< -Parent (Get-SCSMEnumeration -Id "66b02881-ba7a-00ee-8859-b3a6fc8d4a24") -ManagementPackNam
e WNB_CustomMP_IncidentExtensionLists -DisplayName "TestRegion1Add" -Name TestRegion1Add.Enum -Ordinal 800
+ CategoryInfo : NotSpecified: (:) [Add-SCSMEnumeration], ArgumentNullException
+ FullyQualifiedErrorId : System.ArgumentNullException,SMLets.AddSCSMEnumerationCommand

-----------------------------------------------------------------------------------------------------------------------------------------

Thanks,

Ryan

New Post: Add-SCSMEnumeration

$
0
0

got it to work. I wasn't able to get the command working with the -ManagementPackName parameter and used the -ManagementPack parameter instead. My command is posted below.

 

Add-SCSMEnumeration -Parent (Get-SCSMEnumeration -Id "66b02881-ba7a-00ee-8859-b3a6fc8d4a24") -ManagementPack ((Get-SCSMEnumeration -Id "66b02881-ba7a-00ee-8859-b3a6fc8d4a24").GetManagementPack()) -DisplayName "TestRegion1Add" -Name TestRegion1Add.Enum -Ordinal 80

New Post: New-SCQueue - Class problem

$
0
0

Hi.

I'm trying to create a new queue using the New-SCQueue in my Service Manger 2012, but I'm getting the following error:

Error 1:
Found error in 1|ManagementPack.e62ae2df46054d3b9574682ab418e216|1.0.0.0|WorkIt
emGroup.21738d9a0a724b81a6bccd9f0c22ad7d.Discovery/GroupPopulationDataSource||
with message:
The configuration specified for Module GroupPopulationDataSource is not valid.
: Cannot resolve identifier System_WorkItem_ServiceRequest_Library!System.WorkI
tem.ServiceRequest in the context of management pack ManagementPack.e62ae2df460
54d3b9574682ab418e216. Unknown alias: System_WorkItem_ServiceRequest_Library

The command that I'm executing is:

$class = get-scsmclass System.WorkItem.ServiceRequest$
$MP = get-scsmmanagementpack ManagementPack.e62ae2df46054d3b9574682ab418e216 

$QN = "ServiceRequest - Priority 1"
$QD = "..."

new-scqueue -Name $QN -Description $QD -Class $class -ManagementPack $MP -Filter $filter -Verbose -WhatIf

I got the configuration from a queue that I had created in the console and the class is: CustomSystem_WorkItem_ServiceRequest_Library
Using the command Get-SCSMManagementPackReference -ManagementPack $MP i got the following result:
Alias                                           Name                                                           
-----                                           ----                                                           
RunbookActivity                                 ServiceManager.RunbookActivity.Library                         
EnterpriseManagement                            Microsoft.EnterpriseManagement.ServiceManager.UI.Console       
CustomSystem_Notifications_Library              System.Notifications.Library                                   
CustomSystem_WorkItem_Library                   System.WorkItem.Library                                        
CustomServiceManager_SLAManagement_Library      ServiceManager.SLAManagement.Library                           
ServiceCatalog1                                 ServiceManager.ServiceCatalog.Library                          
System_Calendar_Library                         System.Calendar.Library                                        
EnterpriseManagement1                           Microsoft.EnterpriseManagement.ServiceManager.UI.Authoring     
Microsoft_SystemCenter_ServiceDesigner_Library  Microsoft.SystemCenter.ServiceDesigner.Library                 
CustomServiceManager_IncidentManagement_Library ServiceManager.IncidentManagement.Library                      
CustomMicrosoft_Windows_Library                 Microsoft.Windows.Library                                      
ServiceCatalog                                  System.ServiceCatalog.Library                                  
CustomServiceManager_ServiceRequest_Library     ServiceManager.ServiceRequest.Library                          
CustomSystem_SupportingItem_Library             System.SupportingItem.Library                                  
ConfigurationManagement                         ServiceManager.ConfigurationManagement.Library                 
System_SLA_Library                              System.SLA.Library                                             
InstanceGroup                                   Microsoft.SystemCenter.InstanceGroup.Library                   
CustomSystem_WorkItem_ServiceRequest_Library    System.WorkItem.ServiceRequest.Library                         
CustomSystem_WorkItem_Activity_Library          System.WorkItem.Activity.Library                               
System_Library                                  System.Library                                                 
CustomMicrosoft_SystemCenter_Orchestrator       Microsoft.SystemCenter.Orchestrator                            
SystemCenter                                    Microsoft.SystemCenter.Library                                 
CustomSystem_WorkItem_Incident_Library          System.WorkItem.Incident.Library                               
SystemCenter1                                   Microsoft.SystemCenter.Subscriptions                           
EnterpriseManagement2                           Microsoft.EnterpriseManagement.ServiceManager.UI.Administration

Any help would be appreciated.
 
Thanks in advance.

New Post: New-SCQueue - Class problem

$
0
0

We are trying to add a queue aswell

If i create a new MP and the run the command new-scqueue i works,

But if the MP is already in the system we get the same error

 

Error 1:
Found error in 1|ManagementPack.3138166bd07549df910215aebee04528|1.0.0.0|WorkItemGroup.5835bda5be2b459da972db6f2b364211
.Discovery/GroupPopulationDataSource|| with message:
The configuration specified for Module GroupPopulationDataSource is not valid.
: Cannot resolve identifier System_WorkItem_Incident_Library!System.WorkItem.Incident in the context of management pack
 ManagementPack.3138166bd07549df910215aebee04528. Unknown alias: System_WorkItem_Incident_Library

Any help would be appreciated aswell

 

New Post: New-SCQueue - Class problem

$
0
0

One note more.

This Error only happens on MP´s created in the console.

If i add another queue to a MP created with Powershell I dont get the error

 

 


New Post: New-SCSMUserRole

$
0
0

New-SCSMUserRole works but name and discription is emty in the console.

get-SCSMUserRole returns the rigth data .

 

New Post: Can get-scsmobject get a specific property from an extended class?

$
0
0
I am trying to pull a couple of properties from an extended service request fields. I have been attempting this with the get-scsmobject -class smlet but I can't seem to figure out how to get just the value of the property to pipe it to another command. Maybe I should be using another smlet?

New Post: Suggestion for how to get Change Request Areas?

$
0
0

I'm not normally the SCSM 2010 admin for our company, but I'm helping our main SCSM admin out with a project to migrate a bunch of active Change Requests over to new "Areas".  I was able to look at the Change Requests in SCSM using the SMLets one-liner below:

Get-SCSMObject -Class (Get-SCSMClass -Name System.WorkItem.ChangeRequest$) and I've found the Area member, however it's just the GUID of the applicable area.  Are the area's themselves an enumeration in SCSM 2010?  I could go to the DBA and find the SQL table, but was just wondering if there was a good way to tease it out through the SMLets.  Once we get our script together to change all the areas, I'll post it to the Powershell Scriptcenter and cross link it here...

New Post: Suggestion for how to get Change Request Areas?

$
0
0

Nevermind, I just wasn't digging far enough, just had to get the child enumerations:

Get-SCSMEnumeration -Name ChangeAreaEnum | Get-SCSMChildEnumeration

Cheers!

New Post: Can get-scsmobject get a specific property from an extended class?

$
0
0

I was able to get the Information that I was looking for by using this script from Andreas Baumgarten on the SCSM Technet Forums:

import-module smlets

# Get the extended class
$GetClass = Get-SCSMclass -Name ClassExtension_$

# Get the object of an extended class ID equal RA68
$GetObjects = Get-SCSMobject -Class $GetClass| Where-Object{$_.ID -eq "RA68"}
#Output Title of the extended Review Activity ID equal RA68
$GetObjects.Title

The Format List alias was helpful in showing me all the available properties in my extended workitem.

$GetObjects|fl
Viewing all 306 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>