Home Service Manager

Problem with powershell activity

Margarete_JussenMargarete_Jussen Customer Adept IT Monkey ✭✭

I had to Change our PowerShell activity for Service Request Quick and Close. With the following command the Assignment went wrong for our Group Team Netzwerk. We have a Team "Team Netzwerk" and "Team Netzwerk physikalisch". If  I choose Business Service "VPN" the Support Group Setting is set to "Team Netzwerk physikalisch" and not "Team Netzwerk" what it should be.

Get-SCSMObject -ID $id | Set-SCSMObject -Property SupportGroup -Value $Zuweisung.DisplayName

Now I Change the command to the following

Get-SCSMObject -class $SRClass -filter 'ID -eq $SR.ID'  | Set-SCSMObject -Property SupportGroup -value $SupportgroupEnum.name

This works in PowerShell ise but not in Service Manager PowerShell Activity and I am not able to debug it. I tried to use the serveral commands to write the variables to Output but it did not work. Could anyone help with my script? Here is the script Code:

# Autor: mjussen
# Hole SR
$SR = Get-SCSMObject -Id $id
# Parameter Service Request ID
# Definitionen
write-output ('Hallo')
# Service Request Klasse
$SRClass        = Get-SCSMClass -Name System.WorkItem.ServiceRequest$
# Klasse des Benutzers, dem der Request zugewiesen wird
$AssToUserClass = Get-SCSMRelationshipClass -Name System.WorkItemAssignedToUser$
# Ersteller
$CreatedByUser = Get-SCSMRelatedObject -SMObject $SR -Relationship $CreatedByUserClass
# Weise Request dem Ersteller zu
New-SCSMRelationshipObject -Relationship $AssToUserClass -Source $SR -Target $CreatedByUser –Bulk
# Wurde ein Dienst zugeordnet?
$RelatedServiceClass = Get-SCSMRelationshipClass -Name System.WorkItemABoutConfigItem
$AssignedToService =   Get-SCSMRelatedObject -SMObject $SR -Relationship $RelatedServiceClass
if ($AssignedTOService -eq $null) {return}
$ServiceUser = get-SCSMRelatedObject -SMObject $AssignedToService -Relationship (Get-SCSMRelationshipClass -Name IT_AdminGroup)
if ($ServiceUser –eq $null) {return}
echo $ServiceUser
$SupportGroupEnum = Get-SCSMEnumeration |?{$_.DisplayName -eq 'Service Request Support Group'} | Get-SCSMChildEnumeration |?{$_.DisplayName -eq $ServiceUser.DisplayName)}
write-output ($SupportGroupEnum)
write-output ($SRClass)
write-output ($SR.ID)
Get-SCSMObject -class $SRClass -filter 'ID -eq $SR.ID'  | Set-SCSMObject -Property SupportGroup -value $SupportgroupEnum.name


Regards Margret


  • Sean_BeanSean_Bean Customer IT Monkey ✭
    If anyone has any suggestions on how to troubleshoot PowerShell Activity please share.  The only thing I have found is in Event Viewer > Applications and Services Logs > Operations Manager.  When my PSA runs I get an Error - Health Service Modules - Event ID: 33880 - Exception Message: GetSpecificAccountById error...

    My PowerShell script runs fine in ISE.  I'm finding PSA does not like working with the Run as User or when the credentials are stored in the script.  It just sits there running with nothing for me to look at to see what it is doing it just throws the 1 Error in the event viewer.  If I remove the Run as User and the credentials in the script it runs, but I get Access Denied errors in the PowerShell Output and the activity fails...
  • Sean_BeanSean_Bean Customer IT Monkey ✭
    Not sure if this will help you, but I just found a PSLog.  Mine was on my SCSM server under c:\PSALogs.
  • Margarete_JussenMargarete_Jussen Customer Adept IT Monkey ✭✭
    I did already check mit PSLog File but it did not help in my case. But the problem with the script is solved I accidently deleted some lines.
  • Brian_WiestBrian_Wiest Customer Super IT Monkey ✭✭✭✭✭
    When testing your PowerShell script in ISE, are you logged into your workflow server as your account or the service account that PSA is utilizing?
    I also find it best to import your module on each instance to make sure the cmdlets are available to the running instance.
Sign In or Register to comment.