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

New Post: change createdate of incident

$
0
0

 

All the matter in the prescribed format to the OS (Server 2008 R2) was a Russian, I set the format English (U.S.) and everything is OK


New Post: Powershell system.reviewer

$
0
0

Hi Jim,

I'm having issues while trying to add a new System.ReviewActivityHasReviewer relationship, even with a brand new RA:

 

PS C:\> New-SCSMRelationshipObject -Relationship $ActivityHasReviewer-Source $RA-Target $ Reviewer -Bulk
New-SCSMRelationshipObject : A discovery data item was rejected because the item is already bound to another Membership relationship.
At line:1 char:27
+ New-SCSMRelationshipObject <<<<  -Relationship $ActivityHasReviewer-Source $RA-Target $Reviewer-Bulk
    + CategoryInfo          : NotSpecified: (:) [New-SCSMRelationshipObject], DiscoveryDataLifetimeDependencyException
    + FullyQualifiedErrorId : Microsoft.EnterpriseManagement.Common.DiscoveryDataLifetimeDependencyException,SMLets.NewSCSMRelationshipObject

 

I've been using this a lot on my previous job with SCSM 2010... now I'm using 2012 with the latest version of SMLets and it's not working... are you having the same issue?

It's weird that I have no issues while trying to do with the SCSM IP in Orchestrator... but I can't with PowerShell. 

Thanks!

New Post: Powershell Set-SCSMObject decimal value issue

$
0
0

Dear discussion participants,

i got an issue updating decimal values with smlets beta 4 - Set-scsmobject

following error is raised:

VERBOSE: Want to set Cost(decimal) to 56454.58
VERBOSE: Could not find type setter for decimal
Set-SCSMObject : PropertySetterNotFound
At line:1 char:15
+ Set-SCSMObject <<<<  $hwobj -Property cost -Value "56454.58" -WhatIf -Verbose
    + CategoryInfo          : ObjectNotFound: (decimal:String) [Set-SCSMObject], ItemNotFoundException
    + FullyQualifiedErrorId : No such property setter,SMLets.SetSMObjectCommand

VERBOSE: Adding 130bffaf-4f0b-c821-6eaf-b87c2eda5f5b to change list

Any solution possible?

Regards Chris

 

 

New Post: Powershell Set-SCSMObject decimal value issue

$
0
0

Found that is not supported in public void AssignNewValue(ManagementPackProperty p, EnterpriseManagementSimpleObject so,object newValue)

default:
                    WriteVerbose("Could not find type setter for " + PropertyType);
                    WriteError(new ErrorRecord(new ItemNotFoundException("PropertySetterNotFound"),"No such property setter", ErrorCategory.ObjectNotFound, PropertyType));
                    break;


Is it possible to add support for decimal in it?

New Post: New-SCSMRelationshipObject issue

$
0
0

Solution: You have to use -NoCommit flag when creating the activity (just put it right at the end of the creation string). It will be commited on relationship object creation time and the script will work just fine.

This is due to fact that activities use Membership relationship type and have to be commited together with relationship object. Otherwise they get "related" to themselves and refuse to relate to other objects.

If you need more details: http://blogs.msdn.com/b/scplat/archive/2010/04/02/overview-of-relationship-types-in-the-system-center-platform.aspx

New Post: Trying to get the parent CR of a review activity...

$
0
0

Not having much luck with this one, any help much appreciated!

 

$RA_ID = "RA612"

$RAClass = get-SCSMClass -name System.WorkItem.Activity.ReviewActivity$

$ParentCR = Get-SCSMRelationshipObject -Target $RAClass | ?{$_.TargetObject -match $RA_ID}

returns this error,

Get-SCSMRelationshipObject : Object reference not set to an instance of an object.
At line:12 char:39
+ $ParentCR = Get-SCSMRelationshipObject <<<<  -Target $RAClass | ?{$_.TargetObject -match $RA_ID}
    + CategoryInfo          : InvalidOperation: (SMLets.GetSCSMRelationshipObjectCommand:GetSCSMRelationshipObjectCommand) [Get-SCSMRelationshipObject], NullReferenceEx
   ception
    + FullyQualifiedErrorId : RelationshipQuery,SMLets.GetSCSMRelationshipObjectCommand

This is where is it seems to go wrong,

Get-SCSMRelationshipObject -Target $RAClass

PS H:\> Get-SCSMRelationshipObject -Target $RAClass
Get-SCSMRelationshipObject : Object reference not set to an instance of an object.
At line:1 char:27
+ Get-SCSMRelationshipObject <<<<  -Target $RAClass
    + CategoryInfo          : InvalidOperation: (SMLets.GetSCSMRelationshipObjectCommand:GetSCSMRelationshipObjectCommand) [Get-SCSMRelationshipObject], NullReferenceEx
   ception
    + FullyQualifiedErrorId : RelationshipQuery,SMLets.GetSCSMRelationshipObjectCommand

Created Issue: Trouble with object types returned using SMlets [10670]

$
0
0
I am trying to use set-scsmobjecttemplate

$CMN11 = Get-SCSMObjectTemplate -DisplayName &quot;CMN11 - Request for Results Notification&quot;
$CRClassProjection = get-SCSMTypeProjection System.WorkItem.ChangeRequestProjection$
$CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR_ID&quot;
Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11

PS C:\&gt;&gt;&gt; Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11
Set-SCSMObjectTemplate : The template cannot be applied to the instance because the instance is not of t
he template targets type.
At line:1 char:23
+ Set-SCSMObjectTemplate &lt;&lt;&lt;&lt; -Projection $CRP -Template $CMN11
+ CategoryInfo : InvalidOperation: (Template_ae893e...2e7f27753abdbe3:ManagementPackObject
Template) [Set-SCSMObjectTemplate], InvalidOperationException
+ FullyQualifiedErrorId : ApplyTemplate,SMLets.SetSCSMObjectTemplateCommand
And I think this is the cause,
PS C:\&gt;&gt;&gt; $CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR
_ID&quot;
PS C:\&gt;&gt;&gt; $CRP.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object


PS C:\&gt;&gt;&gt; $CRClassProjection.GetType()

IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False PSCustomObject System.Object

And according to the cmdlet help, we are looking for a specific type of object,
PS C:\&gt;&gt;&gt; help Set-SCSMObjectTemplate

NAME
Set-SCSMObjectTemplate

SYNTAX
Set-SCSMObjectTemplate [-Projection] [-Name ] [-Tem
plate ] [-ComputerName ] [-Credential ] [-SCSMSe
ssion ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAc
tion ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer ] [-WhatIf] [-Confirm]
Set-SCSMObjectTemplate [-Object] [-Name ] [-Template ] [-ComputerName ] [-Credential ] [-SCSMSession ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer
] [-WhatIf] [-Confirm]

Commented Issue: Trouble with object types returned using SMlets [10670]

$
0
0
I am trying to use set-scsmobjecttemplate<br><br>$CMN11 = Get-SCSMObjectTemplate -DisplayName &quot;CMN11 - Request for Results Notification&quot;<br>$CRClassProjection = get-SCSMTypeProjection System.WorkItem.ChangeRequestProjection$<br>$CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR_ID&quot;<br>Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11<br><br>PS C:\&gt;&gt;&gt; Set-SCSMObjectTemplate -Projection $CRP -Template $CMN11<br>Set-SCSMObjectTemplate : The template cannot be applied to the instance because the instance is not of t<br>he template targets type.<br>At line:1 char:23<br>+ Set-SCSMObjectTemplate &lt;&lt;&lt;&lt; -Projection $CRP -Template $CMN11<br> + CategoryInfo : InvalidOperation: (Template_ae893e...2e7f27753abdbe3:ManagementPackObject<br> Template) [Set-SCSMObjectTemplate], InvalidOperationException<br> + FullyQualifiedErrorId : ApplyTemplate,SMLets.SetSCSMObjectTemplateCommand <br>And I think this is the cause, <br>PS C:\&gt;&gt;&gt; $CRP = Get-SCSMObjectProjection -Projection $CRClassProjection -Filter &quot;Id -eq $CR<br>_ID&quot;<br>PS C:\&gt;&gt;&gt; $CRP.GetType()<br><br>IsPublic IsSerial Name BaseType<br>-------- -------- ---- --------<br>True False PSCustomObject System.Object <br><br><br>PS C:\&gt;&gt;&gt; $CRClassProjection.GetType()<br><br>IsPublic IsSerial Name BaseType<br>-------- -------- ---- --------<br>True False PSCustomObject System.Object<br><br>And according to the cmdlet help, we are looking for a specific type of object, <br>PS C:\&gt;&gt;&gt; help Set-SCSMObjectTemplate<br><br>NAME<br> Set-SCSMObjectTemplate<br><br>SYNTAX<br> Set-SCSMObjectTemplate [-Projection] [-Name ] [-Tem<br> plate ] [-ComputerName ] [-Credential ] [-SCSMSe<br> ssion ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAc<br> tion ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer ] [-WhatIf] [-Confirm]<br> Set-SCSMObjectTemplate [-Object] [-Name ] [-Template ] [-ComputerName ] [-Credential ] [-SCSMSession ] [-Verbose] [-Debug] [-ErrorAction ] [-WarningAction ] [-ErrorVariable ] [-WarningVariable ] [-OutVariable ] [-OutBuffer<br> ] [-WhatIf] [-Confirm]
Comments: ** Comment from web user: JFadmin **

I found that I was attempting to use this cmdlet incorrectly. I was trying to apply an email notification template.


Created Issue: System.Exception: The specified snap-in 'SMlets' failed to load [10705]

$
0
0
System.Exception: The specified snap-in 'SMlets' failed to load with below exception

System.Management.Automation.PSArgumentException: No snap-ins have been registered for Windows PowerShell version 2.

I have created several powershell scripts that run fine with I run them on the server, however, when I package them in the SM Authoring tool, and deploy them (import MP &amp; copy DLLs) they fail to load the SMlets module.

I believe I have beta3 installed. (how do I check?)

This is SCSM 2012 - on all x64 server Windows 2008 R2

I was initially trying to have the module load via the GUI option in the Authoring tool, then i tried to remove that, and add the import and removal directly in the script.

But is keeps faling with that error... I have only installed SMlets on the management server, not the DW... (do I need to?)

Here is a simple script that fails.
$a = (get-module|%{$_.name}) -join &quot; &quot;
if(!$a.Contains(&quot;SMLets&quot;)){Import-Module SMLets -ErrorVariable err -Force}

$CRClass = get-scsmclass -name System.WorkItem.ChangeRequest$
$CRobj = Get-SCSMObject -Class $CRClass -Filter &quot;ID -eq $CRID&quot;

if ($CRobj.Status.displayname -eq &quot;approved&quot;)
{
$i = 0
if ($CRobj.ActualStartDate -ne $null) {$i++}
if ($CRobj.ActualEndDate -ne $null) {$i++}
if ($CRobj.ImplementationResults -ne $null) {$i++}
}

if ($i -eq 3){Set-SCSMObject -SMObject $CRobj -Property status -Value &quot;executed&quot;}

Remove-module smlets -force

Commented Issue: System.Exception: The specified snap-in 'SMlets' failed to load [10705]

$
0
0
System.Exception: The specified snap-in 'SMlets' failed to load with below exception

System.Management.Automation.PSArgumentException: No snap-ins have been registered for Windows PowerShell version 2.

I have created several powershell scripts that run fine with I run them on the server, however, when I package them in the SM Authoring tool, and deploy them (import MP &amp; copy DLLs) they fail to load the SMlets module.

I believe I have beta3 installed. (how do I check?)

This is SCSM 2012 - on all x64 server Windows 2008 R2

I was initially trying to have the module load via the GUI option in the Authoring tool, then i tried to remove that, and add the import and removal directly in the script.

But is keeps faling with that error... I have only installed SMlets on the management server, not the DW... (do I need to?)

Here is a simple script that fails.
$a = (get-module|%{$_.name}) -join &quot; &quot;
if(!$a.Contains(&quot;SMLets&quot;)){Import-Module SMLets -ErrorVariable err -Force}

$CRClass = get-scsmclass -name System.WorkItem.ChangeRequest$
$CRobj = Get-SCSMObject -Class $CRClass -Filter &quot;ID -eq $CRID&quot;

if ($CRobj.Status.displayname -eq &quot;approved&quot;)
{
$i = 0
if ($CRobj.ActualStartDate -ne $null) {$i++}
if ($CRobj.ActualEndDate -ne $null) {$i++}
if ($CRobj.ImplementationResults -ne $null) {$i++}
}

if ($i -eq 3){Set-SCSMObject -SMObject $CRobj -Property status -Value &quot;executed&quot;}

Remove-module smlets -force
Comments: ** Comment from web user: JFadmin **

I was able to fix this by calling the SMlets module with the literal Path.

$a = (get-module|%{$_.name}) -join " "
if(!$a.Contains("SMLets")){Import-Module 'C:\Program Files\Common Files\SMLets\SMLets.psd1' -ErrorVariable err -Force}

Created Issue: Unable to import module after upgrading to SCSM 2012 SP1 [10764]

$
0
0
After upgrading to SCSM 2012 SP1, the following exception is thrown when attempting to import the SMlets module. I suspect they will need a recompile against the the SP1 bits.

Command execution stopped because the preference variable &quot;ErrorActionPreference&quot; or common parameter is set to Stop: Cannot load Windows PowerShell snap-in C:\Program Files\Common Files\SMLets\SMLets.Module.dll because of the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Loader Exceptions:

Could not load file or assembly 'Microsoft.EnterpriseManagement.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EnterpriseManagement.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'Microsoft.EnterpriseManagement.Core, Version=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

New Post: Using New-SCSMIncident to add support group (nested) e.g. ABC\1LS

$
0
0

With very little powershell knowledge I managed to bodge a little app together that created, resolved and closed incidents for my service desk staff.

They basically put an end user name in and click on a button that refers to the problem for stuff service desk people do on the fly, e.g. username click changed password.

Anyway....

Its been quite popular and a few other teams where I work want to use it too, I have an issue though that their support groups are nested

e.g.

dept1\

dept1\1LS

dept1\2LS

I had a unique name for my dept so this wasn't an issue, New-SCSMIncident .......

with

–SupportGroup "ICT"

was fine, but it won't accept

–SupportGroup "dept1\2LS"

it would accept "2LS" but this could be any 1 of 4 departments.

Any ideas? could I somehow use the full enumeration string?

thanks

Paul Wilson

New Post: Using New-SCSMIncident to add support group (nested) e.g. ABC\1LS

$
0
0

Have you tried getting the child support group first?  It would look something like this (note that example is for incidents):

$supportgroup = get-scsmchildenumeration -enumeration (get-scsmenumeration -name tierqueue | where {$_.name -eq 'dept1'}) | where {$_.displayname -eq '2LS'}

Then insert $supportgroup in place of "depts1\2LS" in your above example.

Or you should just be able to set the -supportgroup switch to "(get-scsmchildenumeration -enumeration (get-scsmenumeration -name tierqueue | where {$_.name -eq 'dept1'}) | where {$_.displayname -eq '2LS'})" (without quotes).

I haven't tried this, but hopefully that would work.

New Post: Using SMlets for classes other than the standard commands

$
0
0

Are you looking for information on how to update an incident using get-scsmobject, or what is the goal for using the get-scsmobject cmdlet?

To get the class, you'll want to run the following:

get-scsmclass -name system.workitem.incident | where {$_.displayname -eq "incident"}

Using this in the get-scsmobjet cmdlet:

get-scsmobject -class (get-scsmclass -name system.workitem.incident | where {$_.displayname -eq "incident"})

This will retrieve all incidents in the system.  If you want to filter on a specific IR, you'll want to add the filter switch:

get-scsmobject -class (get-scsmclass -name system.workitem.incident | where {$_.displayname -eq "incident"}) -filter "Id -eq IR9999"

Hope this helps!

 

 

 

Created Issue: -UserComment switch for Set-SCSMIncident is not documented [10770]

$
0
0
-UserComment switch for Set-SCSMIncident (original work item 7118) is not document in usage syntax. Please add it to usage syntax so it is easily discoverable

New Post: Using New-SCSMIncident to add support group (nested) e.g. ABC\1LS

$
0
0

The first option worked a treat, thanks very much

New Post: Trying to remove "Pending deletion" items cause a lot of (yellow) warnings

$
0
0

Greetings,

I currently have around 347 items stored in the "deleted items" view, in the administration pane. When using the below PowerShell script, which in turn uses SMLets commands, nothing happens:

import-module smlets
$class = Get-SCSMClass | where{$_.name -match “system.configitem”}
$deletedobjects = Get-SCSMObject -class $class | where{$_.objectstatus -match “Pending”}
$deletedobjects | set-scsmobject -property objectstatus -value deleted

$DeletedObjects however never gets filled. There are a lot of yellow warnings on the screen about a "DisplayName" already being present. After that, nothing.

I'm also unsure if the command  triggers the grooming part of SCSM, which is also explained on:

  • http://blogs.technet.com/b/servicemanager/archive/2009/09/18/data-retention-policies-aka-grooming-in-the-servicemanager-database.aspx  

Anyone got any idea?

New Post: Trying to remove "Pending deletion" items cause a lot of (yellow) warnings

$
0
0

I'm not sure about the set-scsmobject cmdlet you are using, however when we want to remove an object for immediate purging, we use remove-scsmobject.

As far as being able to populate your $deletedobjects variable, I looked at the object status of one of our objects in the deleted items folder, and it has an objectstatus of "Pending Delete", so your script looks correct.

Also, you are pulling every config item in the system.configitem class before filtering. It would be better (and faster) if you add a filter before passing the result to the where-object cmdlet. This would look like this:

Get-SCSMObject -class $class -filter "objectstatus -match Pending"

Can you try to select just one of your pending delete objects and see if you still see those warnings? You might try something like " $deletedobject = get-scsmobject -class $class -filter "displayname -eq enterobjectdisplayname" "

New Post: issue using -filter switch on get-scsmobject

$
0
0
Having trouble with this bit of code... the -filter is not working as I would expect.

$MAID is set from the authoring tool

Everything works up to the last line.

Gets the MAobj

$MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"

Filters out the All Activites Q, (no other Qs exist)

$ParentCR = Get-SCSMRelationshipObject -ByTarget $MAobj | ? {$_.sourceobject.tostring() -ne "All Activities Queue"}

Gets the CR displayname from the source object in the relationship

[string]$CRdisplayname = $ParentCR.SourceObject.DisplayName

Attempts to pull the CR based on the above values.

$CRobj = Get-SCSMObject -Class $CRClass -Filter "Displayname -eq $CRdisplayname"

Nothing is returned, no error... no results.

But if I do this,

Get-SCSMObject -Class $CRClass | ?{$_.displayname -eq "CR7554: Are we able to hide these in the Navigation Pane?"}

I get the CR as expected. I can even do this,

Get-SCSMObject -Class $CRClass | ?{$_.displayname -eq "$CRdisplayname?"}

And it works as expected.

New Post: issue using -filter switch on get-scsmobject

$
0
0
Additionally, I have removed the extra Queue, and simplified the code, and still have the same issue...
$MAobj = Get-SCSMObject -Class $MAClass -Filter "ID -eq $MAID"
[string]$CRDisplayname = (Get-SCSMRelationshipObject -ByTarget $MAobj).sourceobject.displayname
$CRobj = Get-SCSMObject -Class $CRClass -Filter "Displayname -eq $CRDisplayname"
Viewing all 306 articles
Browse latest View live


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