Answer the question
In order to leave comments, you need to log in
Why, after creating an AD object, it is impossible to immediately see information about it using Get-..?
Tell me how to fix it, there is a script that creates, for example, a group in AD, then displays information about the created group, for example:
New-ADGroup "$GroupName" -path "$OU" -Description "$Path" -GroupScope Global -PassThru –Verbose
Get-ADGroup "$GroupName" -Properties * | Select-Object Name, whenCreated, CanonicalName
Answer the question
In order to leave comments, you need to log in
Did not have time to replicate, in fact. And to connect to a specific (writable) AD controller, cmdlets have the `-DomainController` or `-Server` parameter, which can be selected at the very beginning of the script and work only with it. And the full list of parameters can be viewed by Get-Help Get-ADGroup -Full, or -Detailed if examples are needed.
@vesper-bot already gave you the reason.
If you want to fix it, then you don’t need to use Get-ADGroup
, New -ADGroup has already returned everything to you, you use -PassThru
If you need to use it, assign it to a variable and output it
or use it | Tee-Object -Variable 'group'
to write down information to the $group variable and show on the screen at the same time
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question