1

Here is my code:

$var = Get-ADUser -Identity username | Select -Property ObjectGUID

Echo $var

My output is :

ObjectGUID    
-------------
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX

I dont want the headers in the variable, so i can pass it to commands with ease.

Please send help and caffiene.

boxdog
  • 7,894
  • 2
  • 18
  • 27

2 Answers2

1

Try this:

$var = Get-ADUser -Identity username | Select-Object -ExpandProperty ObjectGUID
mklement0
  • 382,024
  • 64
  • 607
  • 775
Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
0

You are confusing the default output with the actual contents of your variable. $var contains an object which has a property called ObjectGUID. The default output is just showing you this.

To see only the value of ObjectGUID, simply type (echo, or its underlying command Write-Output, is typically not needed):

$var.ObjectGUID

To use it as input to another cmdlet, you can do things like:

$var.ObjectGUID | My-Command

or

My-Command -Guid $var.ObjectGUID
boxdog
  • 7,894
  • 2
  • 18
  • 27