Powershell script to scan for Expired SSL certificate for all server in OU not working












0















I have used the DOMAINAdministrator account is used for the credentials to run the below PowerShell script to scan for Expired SSL certificate:



$ScriptBlock = {
Get-ChildItem Cert:*My -Recurse |
Select-Object Subject,
DnsNameList,
NotAfter,
NotBefore,
Thumbprint,
Issuer,
@{n = "SAN"; e = {Try {($_.Extensions | Where-Object {$_.Oid.Value -eq '2.5.29.17'}).Format(0)} Catch {} }},
@{n = "IsValid"; e = {$today = Get-Date; If ( $_.NotBefore -lt $today -and $_.NotAfter -gt $today ) { $true } Else {$false} } } }

$computers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "OU=Servers,OU=Production Site 1,DC=Domain,DC=com" |
Where-Object {Test-Connection $_.Name -Count 1 -Quiet} |
Select-Object -expandProperty DnsHostName |
Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

$adCred = Get-Credential Invoke-Command -ComputerName $computers
-ScriptBlock $ScriptBlock -Credential $adCred


But, then I got the error:




[Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData]
Connecting to remote server
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData failed
with the following error message : WinRM cannot process the request.
The following error occurred while using Kerberos authentication:
Cannot find the computer
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData. Verify
that the computer exists on the network and that the name provided is
spelled correctly. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (Microsoft.Power...FormatEntryData:String) , PSRemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken




How to fix it so I can get the CSV result?



The updated error code is now:




Invoke-Command : Cannot validate argument on parameter 'ComputerName'.
The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again. At line:19 char:30
+ Invoke-Command -ComputerName $computers -ScriptBlock $ScriptBlock -Cr ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand











share|improve this question




















  • 1





    Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

    – TobyU
    Nov 21 '18 at 13:29






  • 1





    Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

    – Scepticalist
    Nov 21 '18 at 13:34






  • 1





    As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:49











  • I have already updated the code with the formatting, it is now complaining for the same error.

    – Senior Systems Engineer
    Nov 21 '18 at 22:20






  • 1





    Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

    – halfer
    Dec 1 '18 at 9:31
















0















I have used the DOMAINAdministrator account is used for the credentials to run the below PowerShell script to scan for Expired SSL certificate:



$ScriptBlock = {
Get-ChildItem Cert:*My -Recurse |
Select-Object Subject,
DnsNameList,
NotAfter,
NotBefore,
Thumbprint,
Issuer,
@{n = "SAN"; e = {Try {($_.Extensions | Where-Object {$_.Oid.Value -eq '2.5.29.17'}).Format(0)} Catch {} }},
@{n = "IsValid"; e = {$today = Get-Date; If ( $_.NotBefore -lt $today -and $_.NotAfter -gt $today ) { $true } Else {$false} } } }

$computers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "OU=Servers,OU=Production Site 1,DC=Domain,DC=com" |
Where-Object {Test-Connection $_.Name -Count 1 -Quiet} |
Select-Object -expandProperty DnsHostName |
Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

$adCred = Get-Credential Invoke-Command -ComputerName $computers
-ScriptBlock $ScriptBlock -Credential $adCred


But, then I got the error:




[Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData]
Connecting to remote server
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData failed
with the following error message : WinRM cannot process the request.
The following error occurred while using Kerberos authentication:
Cannot find the computer
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData. Verify
that the computer exists on the network and that the name provided is
spelled correctly. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (Microsoft.Power...FormatEntryData:String) , PSRemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken




How to fix it so I can get the CSV result?



The updated error code is now:




Invoke-Command : Cannot validate argument on parameter 'ComputerName'.
The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again. At line:19 char:30
+ Invoke-Command -ComputerName $computers -ScriptBlock $ScriptBlock -Cr ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand











share|improve this question




















  • 1





    Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

    – TobyU
    Nov 21 '18 at 13:29






  • 1





    Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

    – Scepticalist
    Nov 21 '18 at 13:34






  • 1





    As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:49











  • I have already updated the code with the formatting, it is now complaining for the same error.

    – Senior Systems Engineer
    Nov 21 '18 at 22:20






  • 1





    Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

    – halfer
    Dec 1 '18 at 9:31














0












0








0








I have used the DOMAINAdministrator account is used for the credentials to run the below PowerShell script to scan for Expired SSL certificate:



$ScriptBlock = {
Get-ChildItem Cert:*My -Recurse |
Select-Object Subject,
DnsNameList,
NotAfter,
NotBefore,
Thumbprint,
Issuer,
@{n = "SAN"; e = {Try {($_.Extensions | Where-Object {$_.Oid.Value -eq '2.5.29.17'}).Format(0)} Catch {} }},
@{n = "IsValid"; e = {$today = Get-Date; If ( $_.NotBefore -lt $today -and $_.NotAfter -gt $today ) { $true } Else {$false} } } }

$computers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "OU=Servers,OU=Production Site 1,DC=Domain,DC=com" |
Where-Object {Test-Connection $_.Name -Count 1 -Quiet} |
Select-Object -expandProperty DnsHostName |
Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

$adCred = Get-Credential Invoke-Command -ComputerName $computers
-ScriptBlock $ScriptBlock -Credential $adCred


But, then I got the error:




[Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData]
Connecting to remote server
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData failed
with the following error message : WinRM cannot process the request.
The following error occurred while using Kerberos authentication:
Cannot find the computer
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData. Verify
that the computer exists on the network and that the name provided is
spelled correctly. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (Microsoft.Power...FormatEntryData:String) , PSRemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken




How to fix it so I can get the CSV result?



The updated error code is now:




Invoke-Command : Cannot validate argument on parameter 'ComputerName'.
The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again. At line:19 char:30
+ Invoke-Command -ComputerName $computers -ScriptBlock $ScriptBlock -Cr ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand











share|improve this question
















I have used the DOMAINAdministrator account is used for the credentials to run the below PowerShell script to scan for Expired SSL certificate:



$ScriptBlock = {
Get-ChildItem Cert:*My -Recurse |
Select-Object Subject,
DnsNameList,
NotAfter,
NotBefore,
Thumbprint,
Issuer,
@{n = "SAN"; e = {Try {($_.Extensions | Where-Object {$_.Oid.Value -eq '2.5.29.17'}).Format(0)} Catch {} }},
@{n = "IsValid"; e = {$today = Get-Date; If ( $_.NotBefore -lt $today -and $_.NotAfter -gt $today ) { $true } Else {$false} } } }

$computers = Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*Server*"} -SearchBase "OU=Servers,OU=Production Site 1,DC=Domain,DC=com" |
Where-Object {Test-Connection $_.Name -Count 1 -Quiet} |
Select-Object -expandProperty DnsHostName |
Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

$adCred = Get-Credential Invoke-Command -ComputerName $computers
-ScriptBlock $ScriptBlock -Credential $adCred


But, then I got the error:




[Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData]
Connecting to remote server
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData failed
with the following error message : WinRM cannot process the request.
The following error occurred while using Kerberos authentication:
Cannot find the computer
Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData. Verify
that the computer exists on the network and that the name provided is
spelled correctly. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (Microsoft.Power...FormatEntryData:String) , PSRemotingTransportException
+ FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken




How to fix it so I can get the CSV result?



The updated error code is now:




Invoke-Command : Cannot validate argument on parameter 'ComputerName'.
The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again. At line:19 char:30
+ Invoke-Command -ComputerName $computers -ScriptBlock $ScriptBlock -Cr ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Command], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.InvokeCommandCommand








powershell scripting active-directory windows-scripting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 1 '18 at 9:31









halfer

14.5k758111




14.5k758111










asked Nov 21 '18 at 13:24









Senior Systems EngineerSenior Systems Engineer

282818




282818








  • 1





    Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

    – TobyU
    Nov 21 '18 at 13:29






  • 1





    Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

    – Scepticalist
    Nov 21 '18 at 13:34






  • 1





    As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:49











  • I have already updated the code with the formatting, it is now complaining for the same error.

    – Senior Systems Engineer
    Nov 21 '18 at 22:20






  • 1





    Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

    – halfer
    Dec 1 '18 at 9:31














  • 1





    Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

    – TobyU
    Nov 21 '18 at 13:29






  • 1





    Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

    – Scepticalist
    Nov 21 '18 at 13:34






  • 1





    As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:49











  • I have already updated the code with the formatting, it is now complaining for the same error.

    – Senior Systems Engineer
    Nov 21 '18 at 22:20






  • 1





    Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

    – halfer
    Dec 1 '18 at 9:31








1




1





Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

– TobyU
Nov 21 '18 at 13:29





Cannot find the computer = looks like you're trying to connect to a computer which does not exist, is offline or otherwise not reachable

– TobyU
Nov 21 '18 at 13:29




1




1





Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

– Scepticalist
Nov 21 '18 at 13:34





Your code suggest you have $erroractionpreference set to silent or ignore, which is horrible for developing code. You have repeating expand statements here which will error out: $computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation

– Scepticalist
Nov 21 '18 at 13:34




1




1





As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

– mklement0
Nov 21 '18 at 13:49





As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

– mklement0
Nov 21 '18 at 13:49













I have already updated the code with the formatting, it is now complaining for the same error.

– Senior Systems Engineer
Nov 21 '18 at 22:20





I have already updated the code with the formatting, it is now complaining for the same error.

– Senior Systems Engineer
Nov 21 '18 at 22:20




1




1





Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

– halfer
Dec 1 '18 at 9:31





Note we prefer a technical style of writing here. We gently discourage greetings, hope-you-can-helps, thanks, advance thanks, notes of appreciation, regards, kind regards, signatures, please-can-you-helps, chatty material and abbreviated txtspk, pleading, how long you've been stuck, voting advice, meta commentary, etc. Just explain your problem, and show what you've tried, what you expected, and what actually happened.

– halfer
Dec 1 '18 at 9:31












1 Answer
1






active

oldest

votes


















2














This line is incorrect for a start



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation


Should be



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation





share|improve this answer



















  • 2





    To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:52











  • Cool, thanks for the assistance :-)

    – Senior Systems Engineer
    Dec 2 '18 at 11:30











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413041%2fpowershell-script-to-scan-for-expired-ssl-certificate-for-all-server-in-ou-not-w%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









2














This line is incorrect for a start



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation


Should be



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation





share|improve this answer



















  • 2





    To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:52











  • Cool, thanks for the assistance :-)

    – Senior Systems Engineer
    Dec 2 '18 at 11:30
















2














This line is incorrect for a start



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation


Should be



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation





share|improve this answer



















  • 2





    To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:52











  • Cool, thanks for the assistance :-)

    – Senior Systems Engineer
    Dec 2 '18 at 11:30














2












2








2







This line is incorrect for a start



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation


Should be



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation





share|improve this answer













This line is incorrect for a start



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation


Should be



$computers = Get-ADComputer -Filter {Enabled -eq $True} -SearchBase "OU=Servers,OU=Production,DC=Domain,DC=com" | Select-Object -expandProperty DnsHostName | Export-Csv -Path C:LogsSSL.csv -NoTypeInformation






share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 13:41









ScepticalistScepticalist

416210




416210








  • 2





    To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:52











  • Cool, thanks for the assistance :-)

    – Senior Systems Engineer
    Dec 2 '18 at 11:30














  • 2





    To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

    – mklement0
    Nov 21 '18 at 13:52











  • Cool, thanks for the assistance :-)

    – Senior Systems Engineer
    Dec 2 '18 at 11:30








2




2





To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

– mklement0
Nov 21 '18 at 13:52





To spell it out: Pipeline segment Select-Object -expandProperty DnsHostName was accidentally duplicated in the original command, and you removed the duplicate (it would help to add that description, and to spread the command across multiple lines). As an aside: It's best to avoid the use of script blocks ({ ... }) as -Filter arguments.

– mklement0
Nov 21 '18 at 13:52













Cool, thanks for the assistance :-)

– Senior Systems Engineer
Dec 2 '18 at 11:30





Cool, thanks for the assistance :-)

– Senior Systems Engineer
Dec 2 '18 at 11:30


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53413041%2fpowershell-script-to-scan-for-expired-ssl-certificate-for-all-server-in-ou-not-w%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy