How can i write to powershell?

hello,

i started powershell with run cmd activity with this properties:
exe name:powershell.exe
running as admin
working directory: powershell.exe’s file path

than i tried to click with icu results. than i wanted to write command with keyboard activity. but it didnt clicked. i got posX and posY values. can you help me? thanks.

also i can run a textfile with .ps extension which one includes codes that i want to run.

hello,

I could not understand, why do you try to click somewhere by powershell? Or i misunderstood?

Powershell or cmd commands are ran in background so you can not see anything on screen while process is running.

hello sir,

i used shall task activity. i have a command with more than 10 lines as a ps script that i have to run. properties of shall task:
command: powershell.exe
argument1:${psScript} → the script variable which includes ps script code.
output: output

with using like that, i couldnt get any output. i tried other commands and i got outputs.

when you try it at ps manually, would you get any result? If it is yes, could you please share script with us to check it?

yes, i got result with manually. there is the script:

Import-Module ActiveDirectory

$employeeNumber = “123”

$user = Get-ADUser -Server company.local -Filter {EmployeeNumber -eq $employeeNumber}

if ($user) {

$userGroups = Get-ADPrincipalGroupMembership -Server company.local -Identity $user
foreach ($group in $userGroups) {
    if ($group.Name -ne "Domain Users") {
        Remove-ADGroupMember -Server company.local -Identity $group -Members $user -Confirm:$false -Verbose
    }
}

Set-ADUser -Server company.local -Identity $user -Clear Manager

Move-ADObject -Server company.local -Identity $user -TargetPath "OU=CMP_ToBeDeleted,DC=company,DC=local"

Disable-ADAccount -Server company.local -Identity $user.SamAccountName -Verbose

} else {
Write-Host “Kullanıcı bulunamadı.”
}

Hello, if your issue is solved, could you please share your solution?

hello again,

i used run cmd activity to run powershell command. when i ticked the run as admin property, i couldnt get any result from cmd and got an error. but when i didnt tick the run as admin property, the command has been run successfully and i got result.

i wrote “cmd.exe” to the exe name property and wrote my ps command to the parameters area. here is an example:

echo Import-Module ActiveDirectory;$employeeNumber = "${employeeNumber}";....other part of command.... > %temp%\RunPs1.ps1 & PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%temp%\RunPs1.ps1'" 2>nul &&exit
2 Likes