# How can i write to powershell?

**URL:** <https://forum.robusta.ai/t/how-can-i-write-to-powershell/613>\
**Category:** ICU\
**Created:** [October 15, 2023, 5:36pm UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613 "2023-10-15T17:36:03Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 15, 2023, 5:36pm UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/1 "2023-10-15T17:36:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 15, 2023, 5:38pm UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/2 "2023-10-15T17:38:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Yasin.Baykan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robusta.ai/yasin.baykan/32/86_2.png) [@Yasin.Baykan](https://forum.robusta.ai/u/Yasin.Baykan)\
**Post date:** [October 16, 2023, 5:22am UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/3 "2023-10-16T05:22:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 16, 2023, 5:35am UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/4 "2023-10-16T05:35:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yasin.Baykan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robusta.ai/yasin.baykan/32/86_2.png) [@Yasin.Baykan](https://forum.robusta.ai/u/Yasin.Baykan)\
**Post date:** [October 16, 2023, 5:38am UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/5 "2023-10-16T05:38:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 16, 2023, 5:43am UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/6 "2023-10-16T05:43:40Z")

</div>

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ı.”  
}

---

<div class="post-metadata">

**Author:** ![Yasin.Baykan](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robusta.ai/yasin.baykan/32/86_2.png) [@Yasin.Baykan](https://forum.robusta.ai/u/Yasin.Baykan)\
**Post date:** [October 17, 2023, 11:44am UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/7 "2023-10-17T11:44:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![karagozenes](https://avatars.discourse-cdn.com/v4/letter/k/41988e/32.png) [@karagozenes](https://forum.robusta.ai/u/karagozenes)\
**Post date:** [October 17, 2023, 12:42pm UTC](https://forum.robusta.ai/t/how-can-i-write-to-powershell/613/8 "2023-10-17T12:42:52Z")

</div>

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:

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

```
