0

i need to add item property but i have many error (unlike to my function code)

killprocess padmin7 notepad.exe
Microsoft.PowerShell.Utility\Write-Error : Impossible d'ajouter un membre du type « Property ». Spécifiez un autre type pour le paramètre MemberTypes.
Au caractère killprocess:7 : 7
+
    + CategoryInfo          : NotSpecified: (:) [Write-Error], CmdletInvocationException
    + FullyQualifiedErrorId : System.Management.Automation.CmdletInvocationException,Microsoft.PowerShell.Commands.WriteErrorCommand
    + PSComputerName        : [localhost]

my workflow source

Workflow killprocess ($srvs ,$process)
{
     $Processes = (Get-WmiObject -Class Win32_Process -ComputerName $Srvs -Filter "name='$([string]::join("' or name='", $process))'")

    foreach -parallel ($process in $processes) {

        $Processes | Add-Member -MemberType Property -Name 'Status' -value 'in Progress'
        $returnval = $process.terminate()

        if($returnval.returnvalue -eq 0) {
            $Processes | Add-Member -MemberType Property -Name 'Status' -value 'Killed'
        }
    }
}

1 Answer 1

1

I suspect the problem is using $process.terminate(). Method invocation of objects is not allowed in workflows.

http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/02/powershell-workflows-restrictions.aspx

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.