Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

AD 60day

$
0
0

hello,

I am trying to put to together a script to search a particular AD container and return all systems in that container that has not logged on in 60 days. its just not working as I planned, any help is welcomed.

$then= (Get-Date).AddDays(-60)

 

$ou="OU=Equipment,OU=Migration,OU=west,OU=east,DC=pc,DC=me,DC=pv,DC=com"

 

Get-ADComputer-PropertiesName,lastLogonDate-Filter {lastLogonDate-lt$then} -SearchBase$ou  |FTName,lastLogonDate

 

 

Get-ADComputer : 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.

FindDisableRemoveComputerAD.ps1:5 char:1

+ Get-ADComputer -Properties Name,lastLogonDate -Filter {lastLogonDate -lt $then}  ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : ResourceUnavailable: (:) [Get-ADComputer], 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.GetADComputer

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles