Once again I will post my question here since its the only access I'm allowed for this paid product.
This script returns access denied when I try to run it. If I run the EXACT same script from the built-in ISE or using powerGUI, I receive no errors and I am presented with the output I expect.
PowerShell Code
Double-click the code block to select all.$runuser = "domain\username" $password = Get-Content "\\server\c$\powershell\restricted\settings.txt" $cred = New-Object System.Management.Automation.PSCredential -ArgumentList @($runuser,(Convertto-SecureString -String $password -AsPlainText -Force)) $connection = $cred $session = New-PSSession "domaincontroller" -credential $cred invoke-command -Session $session -scriptblock {param ($session, $groups) Add-PSSnapin Quest.ActiveRoles.ADManagement $groups = get-qadgroup -sizelimit 0 | Where-Object {$_.GroupType -match 'Security'} | select-object name | Sort-Object name $groups | Out-File "\\server\c$\powershell\test.txt" } -argumentlist $session, $groups $gnames = Get-Content "\\server\c$\powershell\test.txt" Write-Host $gnames