Search
-
Re: Powershell
@Ryan_Kelley the problem is, forgot the -recursive in your first code. Can you try it that way and tell me if it worked $parentSR = Get-SCSMRelationshipObject -ByTarget $myActivity -Relationship $rel -recursive | Where-Object {$_.SourceObject.ClassName -eq'System.WorkItem.ServiceRequest'} | Select-Object -First 1 -
Re: Powershell
@Ryan_Kelley The error lies here: $parentSR = Get-SCSMRelationshipObject -ByTarget $myActivity -Relationship $rel -Recursive:$true | Where-Object {$_.SourceObject.ClassName -eq 'System.WorkItem.ServiceRequest'} | Select-Object -First 1 You receive the relationship object here and not the SourceObject. You filter on the… -
Re: Powershell
@Ryan_Kelley may I ask why you set the $parentSR to the Sourceobject again in this code snippet $parentSR = Get-SCSMObject -Id $parentSR.Id.Guid if ($null -eq $parentSR) { Write-Output "Parent Service Request not found." exit 1 } else { $parentSR = $parentSR.SourceObject } First you assign the SR Object to the variable,… -
Re: Powershell
Thank you! I added the line after: Ticket does not contain the usertexts and also no title nor affecteduser -fun problem - maybe :) # Retrieve the activity object try { $myActivity = Get-SCSMObject -Id $activityId } catch { Write-Output "Failed to retrieve the activity object with ID ${activityId}: $_" exit 1 } # Retrieve… -
Re: Powershell
param([string]$activityId) # Set default computer for SMLets test $GLOBAL:smdefaultcomputer = "testserver" # Import the necessary modules try { if (-not (Get-Module -Name Smlets)) { Import-Module SMLets } } catch { Write-Output "Error importing SMLets module: $_" exit 1 } try { if (-not (Get-Module -Name ActiveDirectory))… -
Re: Powershell
I cannot emphasize how much I am learning and how much I am grateful for the assistance! I implemented the change but it now just says: Cannot bind argument to parameter 'SMObject' because it is null. $parentSR = (Get-SCSMRelationshipObject -ByTarget $myActivity -Relationship $rel -Recursive:$true | Where-Object… -
Re: Powershell
Thank you all for your help! I would never had guessed we were out of date! I updated smlets in our test environment(eventually prod). The service request has been found! If possible: The code below gets the parentSR but I cannot seem to find any usertexts. Is there something else I need to add? I am trying to pull them in… -
Re: Powershell
Hello, Sorry for the late reply -- was on PTO. Objective is to send an email to the affected user's UPN within AD. But I cannot retrieve the parentid and thus cannot find the affected user. SR -> PA -> SA -> AC My code below trying to use the powershell did not work as expected still cannot find the parentid: The output…