Question Afficher nombre de jours restants avant la date d'expiration du mot de passe

Plus d'informations
il y a 1 an 10 mois #32381 par bistoule
Bonjour,

Débutant en powershell, j'ai besoin de vos compétences.

J'ai besoin d'un script powershell pour savoir le nombre de jours restants avant la date d'expiration du mot de passe d'un compte windows Active Directory. Mais la politique de sécurité m'interdit d'utiliser la cmdlet get-aduser comme j'ai pu voir dans de nombreux exemples.

En vous remerciant d'avance.

Bistoule

 

Connexion ou Créer un compte pour participer à la conversation.

Plus d'informations
il y a 1 an 10 mois #32382 par Laurent Dardenne
Salut,
essaie ceci :
Function Get-BasicADObject 
{ 
<# 
    .SYNOPSIS  
        Function allow to get AD object info without AD Module. 
 
    .DESCRIPTION  
        Use Get-BasicADObject to get information about Active Directory objects. 
 
    .PARAMETER Filter  
        Filter objects, default search information about users. 
 
    .PARAMETER Ldap 
        LDAP Path to object. 
         
    .EXAMPLE  
        Get-BasicADObject -Ldap 'dc=domain,dc=com'| Export-Csv C:\ADObj.csv -NoTypeInformation 
 
    .NOTES  
        Author: Michal Gajda (https://gallery.technet.microsoft.com/scriptcenter/Export-AD-Users-properties-eea93c89)
        More Info on ADSISEARCHER: https://blogs.technet.microsoft.com/heyscriptingguy/2010/08/24/use-the-powershell-adsisearcher-type-accelerator-to-search-active-directory/  
#> 
    [CmdletBinding( 
        SupportsShouldProcess=$True, 
        ConfirmImpact="Low" 
    )] 
    param 
    ( 
        [String]$Ldap = "dc="+$env:USERDNSDOMAIN.replace(".",",dc="),         
        [String]$Filter = "(&(objectCategory=person)(objectClass=user))" 
    ) 
 
    Begin{} 
 
    Process 
    { 
        if ($pscmdlet.ShouldProcess($Ldap,"Get information about AD Object")) 
        { 
            $searcher=[adsisearcher]$Filter 
             
            $Ldap = $Ldap.replace("LDAP://","") 
            $searcher.SearchRoot="LDAP://$Ldap" 
            $results=$searcher.FindAll() 
     
            $ADObjects = @() 
            foreach($result in $results) 
            { 
                [Array]$propertiesList = $result.Properties.PropertyNames 
                $obj = New-Object PSObject 
                foreach($property in $propertiesList) 
                {  
                    $obj | add-member -membertype noteproperty -name $property -value ([string]$result.Properties.Item($property)) 
                } 
                $ADObjects += $obj 
            } 
       
            Return $ADObjects 
        } 
    } 
     
    End{} 
}
Ensuite dans ton organisation c'est peut être l'accès à l'AD qui est verrouillé et pas seulement le module powershell ...

Tutoriels PowerShell

Connexion ou Créer un compte pour participer à la conversation.

Temps de génération de la page : 0.066 secondes
Propulsé par Kunena