Powershell export Certificates

Welcome Forums General PowerShell Q&A Powershell export Certificates

This topic contains 1 reply, has 2 voices, and was last updated by

2 years, 5 months ago.

  • Author
  • #54644

    Points: 0
    Rank: Member

    Is all about powershell

    Have created following ps1 :


    Import-Module ActiveDirectory
    # Vnos Lokacije
    [string]$lokacija = Read-Host "Vnesi Lokacijo ..."

    # Današnji Datum
    $datum = Get-Date

    $lokacija = $lokacija.ToUpper()

    # Od danes do 10 dni starih računalnikov / aktivnih 10 dni
    $danes = $datum.AddDays(-10)

    $podatek = Get-ADComputer -SearchBase "OU=$lokacija,DC=dc,DC=dc,DC=com" -Properties * -Filter {LastLogonDate -gt $danes} | Select Name
    Foreach ($podatk in $podatek) {
    Get-Childitem cert:LocalMachine\Root -Recurse
    where-object { $_.Subject -like "*$hostname*" }

    # Export-Csv -Path "C:\Users\kkdruadmin\Desktop\Test.csv"


    And this I would like to export to csv with data of HOSTNAMES in start of every cert (foreach)
    Curently script is exporting all certificates but I can not split it by hostnames (Get-ADComputer|select name)

    Please ... How can I fix this.

  • #54646

    Points: 24
    Team Member
    Rank: Member

    It looks like you're using the wrong variable in your Where-Object filter.

    where-object { $_.Subject -like "*$hostname*" }

    instead of

    where-object { $_.Subject -like "*$podatk*" }

    What do you think?

The topic ‘Powershell export Certificates’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort