cancel
Showing results for 
Search instead for 
Did you mean: 

PowerShell 1.3.1 VBO - Unable to execute Get-ADUser command

sai_bhargavaraj
Level 3

Hi Team, We have a requirement where with user email id we need to know whether he is an active user in organization or user left the organization. In order to do that we are using powershell Get -ADUser commands.

When i pass only powershell script in "PowerShellScriptCode" variable we are not getting any output or no error too. Manually the same script is working fine

Sample - Get-ADUser -property manager, department -Filter {EmailAddress -like "user@xyz.com"}

Please let us know if you have faced this issue or is there any better way to handle this scenario. Thanks in Advance



------------------------------
sai bhargava raja
Consultant
Deloitte
Asia/Kolkata
------------------------------

6 REPLIES 6

Mukeshh_k
MVP

Hi sai bhargava raja - Just to understand this bit more - are you able to run any other powershell script files ?and when you say you were able to run it manually was it inside your robot's environment or your primary account?

I did try running a sample powershell script by just placing the file path in the "Test Script" and using the "Run Script" action and it ran successfully.

24145.png



------------------------------
Kindly up vote this as "Best Answer" if it adds value or resolves your query in anyway possible, happy to help.

Regards,

Mukesh Kumar - Senior Automation Developer

NHS, England, United Kingdom, GB
------------------------------
Regards,

Mukesh Kumar

LeonardoSQueiroz
Level 10
Hello Sai, I carried out the test and it was successful based on the information provided.
 
Check:
 
1. Security settings that may impact script execution.
2. Parameters based on Mukesh's screenshot


------------------------------
Leonardo Soares
RPA Developer
------------------------------
Leonardo Soares RPA Developer América/Brazil

Thank You for the response Mukesh.
Actually i'm using powershell for the first time, please excuse me if my query is not clear.

1.I'm just passing my sample query in "PowerShell Script Code" and not passing any filename or other parameters in Run Script action.

2.Yes when i say manually, i'm able to execute the query/commands in my bot local environment.

Also if you are able to run below command, can you please guide me with few more details/screenshots of it?

Sample - Get-ADUser -property manager, department -Filter {EmailAddress -like "user@xyz.com"}

Thanks in advance



------------------------------
sai bhargava raja
Consultant
------------------------------

Thank you for the response, Leonardo. Can you please provide some more details on the security settings which you mentioned. I will check with my application support team.



------------------------------
sai bhargava raja
Consultant
Deloitte
Asia/Kolkata
------------------------------

sai bhargava raja - I cannot run AD Module as its not available in my machine and if you have it you can customise your script to fetch data from list of email ids in CSV and write back the results to a Text/CSV file as well - Just for testing refer below screenshots for one of other script file I am using -

Example:

I would run my powershell scripts by giving the path of my script file with extension as .ps1 (write the script in notepad and save it with extension as .ps1) - powershell script that I have with me as sample script below is for toggling the caps lock on if its off) -

Script:

if ([console]::CapsLock -ne 'True')
{
    $wsh = New-Object -ComObject WScript.Shell;
    $wsh.SendKeys('{CAPSLOCK}')
}

24148.png

Params for Run Script :

[PowerShellScriptCode] : Get-CimInstance -ClassName Win32_ComputerSystem

[Test Script] : Path of your .ps1 file

24149.png

24150.png



------------------------------
Kindly up vote this as "Best Answer" if it adds value or resolves your query in anyway possible, happy to help.

Regards,

Mukesh Kumar - Senior Automation Developer

NHS, England, United Kingdom, GB
------------------------------
Regards,

Mukesh Kumar

Hello, ask them to check if the security option "Prevent access to command prompt" is enabled.

24152.png

Steps : https://youtu.be/pe6u_XacNbU

Regards,



------------------------------
Leonardo Soares
RPA Developer
------------------------------
Leonardo Soares RPA Developer América/Brazil