Hello,
I have written a script which looks up an AD security group, lists the members and then takes action against each member.
I'm attempting to run this on Server1, which is a Windows 2008 R2 non-DC server.
If I open a Powershell prompt and run this manually, it works perfectly. However, I need to run this as a scheduled task. I've created a scheduled task, and when I run this, it fails. I've done a bit of tinkering and managed to get a transcript of the errors dumped to a text file (which I've outlined below).
Note that these errors do not change regardless of whether I import the AD modules manually at the start of the script (I understand PS v3 is meant to automatically import this module for you when required anyhow on 2008 R2). This script also works perfectly if I manually execute it, so I do not believe it is an issue with ADWS playing up on either of my DC's.
The error is below. Any assistance would be appreciated.
Thanks,
-Ewan
Transcript started, output file is C:\#####\log\testlog.txt
WARNING: Error initializing default drive: 'Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.'.
powershell.exe : Get-ADGroupMember : Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.
At line:1 char:2
+ powershell.exe c:\#####\test.ps1 *> C:\#####\log ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Get-ADGroupMemb...t is currently :String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
At C:\#####\test.ps1:30 char:17
+ $GroupMembers = Get-ADGroupMember $ADGroup -recursive | Select-Object Name # F ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ResourceUnavailable: (WSUS Test Group:ADGroup) [Get-ADGroupMember], ADServerDownException
+ FullyQualifiedErrorId : Unable to contact the server. This may be because this server does not exist, it is currently down, or it does not have the Active Directory Web Services running.,Microsoft.ActiveDirectory.Management.Commands.GetADGroupMember