0

I just started using powershell and i am trying to use the:

Get-ADOrganizationalUnit -Filter 'Name -like "*"' | Format-Table Name, DistinguishedName -A

Remote here for i used

Invoke-Command -ComputerName <name> -ScriptBlock {Get-ADOrganizationalUnit -Filter 'Name -like "*"' | Format-Table Name, DistinguishedName -A} -credential <cred>

but then i get the error

    + CategoryInfo          : InvalidData: (:) [out-lineoutput], ArgumentException
    + FullyQualifiedErrorId : FormatObjectDeserializerNullDataMember,Microsoft.PowerShell.Commands.OutLineOutputComman
   d

I have no clue what to do if i use the command localy it works just fine

0
0

Got it had to use

$session = Invoke-Command -ComputerName 192.168.51.128 -ScriptBlock {
    Get-ADOrganizationalUnit -Filter 'Name -like "*"' 
} -credential $cred

Write-Output $session | Format-Table Name, DistinguishedName -A
1
  • the reason this worked is that the Format-* cmdlets should NEVER be used for anything other than final output to the screen OR final output to a plain text file. save the output of F-T to a $Var and then look at $Var[3] ... you will see lots of red error text AND mention of format in the object type. – Lee_Dailey Apr 21 '20 at 4:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.