I might be missing something, but I am trying to get the GUID from a security group to assign some delegated permissions.
I have a basic code see below;
$guidmap = get-adgroup -Filter "name -like 'MyOU'" -Properties * | select objectguid
Write-host "Here is what you need: " $guidmap
Not sure why I can't seem to resolve the GUID on this.
The thing to remember is that Powershell is very much an object-based language. One of your best debugging tools will be the Get-Member
cmdlet. In this case, it turns out that the output from Select-Object
is still an object of type ADGroup (specifically, Selected.Microsoft.ActiveDirectory.Management.ADGroup
), when what you want is apparently either a System.GUID
or a System.String
.
If you want a System.GUID
, try
$GUIDMap = (Get-ADGroup -Filter "Name -like 'MyOU'" -Properties ObjectGUID).ObjectGUID
or if you want a System.String
, use
$GUIDMap = (Get-ADGroup -Filter "Name -like 'MyOU'" -Properties ObjectGUID).ObjectGUID.GUID
( Incidentally, if you're retrieving the information for a single specific group, you don't need to use the -Filter
parameter and expression; you can use -Identity
instead - Get-ADGroup -Identity MyOU -Properties ObjectGUID
... )
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.