This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Custom Activity PowerShell

Hello,

i have the following issue. If a user changes his password on the pwm website and the user is currently logged on the system, the computer need to be locked so that the new password is recognized by our proxy and windows itself.

I try to create a custom activity with a powershell script that lock down the computer. I know how powershell works but i have no clue how to get a custom activity working. 

Thats an important step for me and i really need to know how it goes. I read the help file but i didn´t get it.

Here is what i am doing so far.

Create a custom activity inside the manage my passwords workflow.

Activity Name: lockpc

Powershell Script.

function PreLoad($workflow, $lockpc)
{
$xCmdString = {rundll32.exe user32.dll,LockWorkStation}

Invoke-Command $xCmdString

# #Add code to be executed before activity execution begins here
}

 

Nothing happens. The Text that i created on the user interface designer is displayed. But nothing more.

I hope that someone put me in the right direction.

Thanks

Frank

Parents
  • Hello George,

    ok, i found that out also. But with the information provided in the $workflow.userinfo i get enough information to do that. I thought. But, there is always a but. It is not working.

    Steps that i have done.

    1. Get the ip address out of the $pmuser = $workflow.userinfo
    $ip = $pmuser.ipaddress

    2. resolve the dns name for the ip
    $client = ([system.net.dns]::GetHostByAddress($ip)).hostname

    3. try to run the local task to lock the pc
    schtasks /run /tn lockpc

    But step 3 did not work. I dont know why. If i do all the steps manually in powershell it is working.
    Also when i try to start the task remotely with the following command.
    schtasks /run /s $Client /tn lockpc

    It is not working. Any ideas?
    Thanks for helping me to resolve it.
    Frank
Reply
  • Hello George,

    ok, i found that out also. But with the information provided in the $workflow.userinfo i get enough information to do that. I thought. But, there is always a but. It is not working.

    Steps that i have done.

    1. Get the ip address out of the $pmuser = $workflow.userinfo
    $ip = $pmuser.ipaddress

    2. resolve the dns name for the ip
    $client = ([system.net.dns]::GetHostByAddress($ip)).hostname

    3. try to run the local task to lock the pc
    schtasks /run /tn lockpc

    But step 3 did not work. I dont know why. If i do all the steps manually in powershell it is working.
    Also when i try to start the task remotely with the following command.
    schtasks /run /s $Client /tn lockpc

    It is not working. Any ideas?
    Thanks for helping me to resolve it.
    Frank
Children
No Data