0 votes

Hello,

I have a simple custom command supposed to get the user name which is connected to as specific computer.

The command line is :

$User = Get-WmiObject -Class Win32_ComputerSystem -ComputerName "%dNSHostName%" | Select-Object UserName

The error is :

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Trace de pile: at <ScriptBlock>, <No file>: line 8

If I connect to the Adaxes server, run a powershell with the same user that is configured for this script, and run the get-wmiobject cmdlet, then it works.

So why I get an access denied from the Adaxes console?

Thanks in advance!

by (1.1k points)

1 Answer

0 votes
by (216k points)

Hello,

PowerShell scripts in Adaxes are executed using the credentials of the Adaxes service account (specified during Adaxes installation), but network operations (e.g. getting instances of WMI objects using the Get-WmiObject cmdlet) are performed using the credentials specified in the Run as section of the Run a program or PowerShell script action. It looks like the account specified in the section does not have the necessary native Active Directory permissions in the domain where the target computer object resides. image.png Please, make sure that the account has the permissions in the domain and check whether the issue persists.

0

Thanks for your answer. I am sure about it, that's the problem. On the adaxes server, I run a powershell with "run as another user" and I used the "This acocunt" login. Doing this way I get the outpout from the cmdlet.

0

We are having this same exact issue after upgrading to 2021. Worked fine in 2017. Running the command manually in Powershell from the Adaxes server as the RunAs user also works fine. Was there ever a solution to this?

0

Hello,

First of all, Adaxes 2017 was using PowerShell 2.0. Adaxes 2021 uses the latest version of PowerShell installed. We were not able to reproduce the issue. If the same accounts are used, the command behaves the very same way in Adaxes and in Windows PowerShell. Maybe, there were some changes in the way the cmdlet works. As a solution, you can try the following approach:

# Get saved credentials.
$username = $Context.RunAs.UserName
$password = $Context.RunAs.Password | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PsCredential($username, $password)

$User = Get-WmiObject -Class Win32_ComputerSystem -ComputerName "%dNSHostName%" -Credential $credential | Select-Object UserName
0

Thank you. I edited our code and added the -credential option and it worked. It seems like for this cmdlet, 2021 is not properly passing the runas into the script. So far, this only seems to be a problem with Get-WMIObject as other Powershell scripts "runas" just fine.

Related questions

0 votes
0 answers

Hi Evryone, I am trying to set up an external portal within a new webserver on dmz, and with only access to a webservice created from selfservice. The new webservice is only ... login, only reset password. What I am mising there that its not working? Thanks,

asked Nov 26, 2021 by yagoityd (20 points)
0 votes
1 answer

I'm trying to create a business rule that is executed before a user is created. I used the Adaxes tutorial Run PowerShell Script after Creating a User for ... execute. Are there permissions I'm forgetting somewhere? Thanks in advance for the assistance.

asked Jun 29, 2021 by lgibbens (320 points)
0 votes
1 answer

I've modified the script here https://www.adaxes.com/script-repository/import-users-to-be-deprovisioned-s3.htm to do bulk deprovisioning of accounts via a .csv file. It ... share and folder. Why is this throwing this error? They path works in file explorer.

asked Mar 26, 2021 by johnsonua (390 points)
0 votes
1 answer

We have multiple servers in our Adaxes cluster. One of the servers is throwing an error of "Access is denied." before a login page even comes ... step) +75 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +158

asked Aug 27, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

Since upgrading to 2019.2 I am no longer able to run scheduled reports, either automatically or manually. When looking at the log I see it fails at the "generate report ... is attempting. I can run the report directly with no problem. Can anyone help? Thanks,

asked Nov 21, 2019 by rossb (20 points)
3,326 questions
3,026 answers
7,727 comments
544,678 users