search cancel

Access denied on Import-Module in a powershell script after upgrade Windows 2019


Article ID: 242995


Updated On:


CA Workload Automation AE


After upgrading our windows servers to windows 2019 and updated autosys agent to 11.5 in order to respect the compatibility matrix.

Since this upgrade, we get an access denied with the command Import-Module ActiveDirectory:

Import-Module : Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer. Contact
Microsoft Customer Support Services.
At Y:\FS-AutoTask\Autosys\test\Delete-Users.ps1:66 char:1
+ Import-Module ActiveDirectory -verbose
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ReadError: (:) [Import-Module], HostException
    + FullyQualifiedErrorId : ReadConsoleOutput,Microsoft.PowerShell.Commands.ImportModuleCommand

runs : The term 'runs' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At Y:\FS-AutoTask\Autosys\test\Delete-Users-ERIC.ps1:69 char:1
+ runs
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (runs:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

This error occurs only when the command is executed through Autosys. 

We tried several execution mode with the same account on the same server:

  • executed directly with a command line
  • executed by a runas
  • executed in scheduled task


Release : 343P

Component :


Added following agent parameters into agentparm.txt