Powershell ISE, Get-AdGroup does not run when started as admin

When i start ISE as admin i run this code:
$Domain = “contoso.com
Get-ADGroup -Identity “Contoso-Windows” -server $Domain

It does not give any results.

When i start ISE normally and run:
$Domain = “contoso.com
Get-ADGroup -Identity “Contoso-Windows” -server $Domain

It gives me back the group name and its properties.

Any one else with this problem? Or with a fix?

When you are running as admin, is this the local machine administrator account? If so, three problem may be that it doesn’t have rights to read from the domain.

As it works with your account, i can only guess that it is a domain account logged into the computer.

That being said, if need alternate credentials for making changes to AD groups, check out the Get-Credential command.

$creds = Get-Credential
$domain = "contoso.com"
Get-ADGroup -identity "Contoso-Windows" -server $domain -credentials $creds