Share via

Powershell workflow and Access Errors

MrFlinstone 761 Reputation points
2021-01-29T16:27:05.843+00:00

I have found that I am getting Access denied errors whilst running a Ps script that uses PowerShell workflows. The error details are as follows. What I also found is that if PowerShell workflows are not used, the script works fine.

Receive-Job : Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer. Contact
Microsoft Customer Support Services.

  • ... Receive-Job -Job $job -Wait -Verbose -Debug -ErrorAction ...
Windows for business | Windows Server | User experience | PowerShell

2 answers

Sort by: Most helpful
  1. MrFlinstone 761 Reputation points
    2021-02-01T15:46:07.737+00:00

    Please see the code snippet below.

        Workflow getAD-Details {   
          
            $objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest()  
            $DCServer = $objForest.NamingRoleOwner.Name  
            $DCServer += ':3268'  
            $search_list =   @('Account1','Account2','Account3','Account4')  
                  
            foreach -parallel -throttlelimit 4 ($account in $search_list) {  
              
            InLineScript {  
          
            $SearchResults = @()  
            $AccountNotFound = @()  
            $account_name = $using:account  
            $ErrorActionPreference = 'Continue'  
          
            try {  
                $SearchResults += Get-ADUser -ErrorAction Stop -identity $account_name  -properties * -Server $using:DCServer |  
                Select-Object  SamAccountName, @{n="Domain"; e={$_.userPrincipalName.Split('@.')[1]}}, Created,createTimeStamp  
            }  
            Catch {  
                Write-Error "The account $account_name does not exist"  
                $AccountNotFound +=    [PSCustomObject]@{  
                    SearchDate = Get-Date  
                    Account = $account_name  
                }  
                  
                }  
                  
              }  
              
           }  
        }  
          
        getAD-Details  
    

    Error details.

    Receive-Job : Win32 internal error "Access is denied" 0x5 occurred while reading the console output buffer. Contact Microsoft Customer Support Services.  
    

    Was this answer helpful?

    0 comments No comments

  2. Rich Matheisen 48,116 Reputation points
    2021-01-29T20:51:16.887+00:00

    Are you trying to get user input within a workflow? If so, why? Workflows are designed to run without user interaction.

    I think you may be able to "InlineScript" a Read-Host, though. I've never tried it.

    powershell-workflows-restrictions

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.