'Unable to run PowerShell Script in GitHub Actions due to ParentContainsErrorRecordException: error
I have a simple work flow file
name: CI
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Get Repos
run: ./Snippet/getrepo2.ps1
env:
PAT: ${{ secrets.My_PAT }} #I have the secret on Github
OrgName: MyOrg
shell: pwsh
However I keep getting the error below when I run the workflow:
ParentContainsErrorRecordException:
Line |
3 | $RawUI.CursorPosition = @{X=0;Y=0}
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Exception setting "CursorPosition": "The handle is invalid."
The PowerShell file looks like:
$PAT = $env:PAT, # This token MUST have admin rights
$OrgName = $env:OrgName
[string]$userName = 'NotNeeded'
[string]$userPassword = $PAT
# Convert to SecureString
[securestring]$secStringPassword = ConvertTo-SecureString $userPassword -AsPlainText -Force
#Create the credential
[pscredential]$credObject = New-Object System.Management.Automation.PSCredential ($userName,$secStringPassword)
Set-GitHubAuthentication -Credential $credObject -SessionOnly -ErrorAction SilentlyContinue
# Access the Organizational Repo
$OrganizationalRepos = Get-GitHubRepository -OrganizationName $OrgName
Write-Host $OrganizationalRepos.name
Any help will be appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
