Active Discovery Script "SPLIT"?
Hello,
I have the following Active Discovery script:
<span class="pln">far the Active Discovery script is:
##--------------- Discovery ------------------##
$pshost = Get-Host # Get the PowerShell Host.
$pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI.
$newsize = $pswindow.BufferSize # Get the UI's current Buffer Size.
$newsize.width = 800 # Set the new buffer's width to 800 columns.
$pswindow.buffersize = $newsize # Set the new Buffer Size as active.
$newsize = $pswindow.windowsize # Get the UI's current Window Size.
$newsize.width = 800 # Set the new Window Width to 800 columns.
$pswindow.windowsize = $newsize # Set the new Window Size as active.
$readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"
$localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"
$store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine )
$store.Open( $readOnly )
$store.Certificates `
| Select-Object { `
$_.Thumbprint + "##" `
+ $_.Issuer + "##" `
+ $_.Subject + $_.Issuer + "##" `
+ "##" `
+ "cert.issuer=" + $_.Issuer `
+ "&cert.friendlyname=" + $_.FriendlyName `
+ "&cert.serialnumber=" + $_.SerialNumber `
+ "&cert.thumbprint=" + $_.Thumbprint `
+ "&cert.split=" + {(($_.Issuer -split ",") |? {$_ -like "CN=*"}) -replace "CN="}
} `
| Format-Table -HideTableHeaders</span>
I am getting the friendlyname, serialnumber, thumbprint are appearing in info on the device and could be used in the report but I do not get the split ... what is wrong with it?
Thanks,
Dom
Dominique
Posted 5 years ago·Last reply 5 years ago
15 comments
Dominique
OP5 years agoYou are correct the script does not show the missing data either:
The days is showing but why the big numbers like way other the 28 7 2 threholds!!!?
The commonname field does not show so this means it should not be the correct parameter... not sure if I should used the $_.Subject, SubjectAlternativeName (SAN) not sure which name it will have..., Issuedto, Issuedby, ...
Trying to find a list of names for all these parameters..
Thanks,
Dom
LM User
·5 years agoWaiting to see it in the report is not the right place to verify that the script is outputting correctly. You should be verifying by using the "Test Active Discovery" button. This will help you ensure that the properties are getting created properly and let you adjust the script so that it outputs the right data.
Dominique
OP5 years agoI could add more fields but IssuedTo, IssuedBy are causing issues, ...
Also the days to expire are not the ones 28 7 2 !!! set in the threshold of the Datasource? Should the threshold set somewhere else?
The content of common name seems blanks : should it be: commonname, Subject, Subject Alternative Name (SAN)... other?
Thanks,
Dom
Dominique
OP5 years agoI remove the "+ "&cert.issuedby=" + (($_.Issuer -split ",") |? {$_ -like "CN=*"}) -replace "CN=" `" from the Active Discovery script and now I am getting:
Checking why this line is removing everything from the report!!!
Thanks,
Dom
Dominique
OP5 years agoChecking ...
Thanks,
Dom
Dominique
OP5 years agoEverything i listed properly in the test Active Discovery but the report does not show anything anymore !!!
Checking ...
Thanks,
Dom
Dominique
OP5 years agoChecking the report now
Dominique
OP5 years agoThis should be the last script:
##--------------- Discovery ------------------##
$pshost = Get-Host # Get the PowerShell Host.
$pswindow = $pshost.UI.RawUI # Get the PowerShell Host's UI.
$newsize = $pswindow.BufferSize # Get the UI's current Buffer Size.
$newsize.width = 800 # Set the new buffer's width to 800 columns.
$pswindow.buffersize = $newsize # Set the new Buffer Size as active.
$newsize = $pswindow.windowsize # Get the UI's current Window Size.
$newsize.width = 800 # Set the new Window Width to 800 columns.
$pswindow.windowsize = $newsize # Set the new Window Size as active.
$readOnly = [System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"
$localMachine = [System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"
$store = new-object System.Security.Cryptography.X509Certificates.X509Store( "\\##SYSTEM.SYSNAME##\my", $localMachine )
$store.Open( $readOnly )
$store.Certificates `
| Select-Object { `
$_.Thumbprint + "##" `
+ $_.Issuer + "##" `
+ $_.Subject + $_.Issuer + $_.NotAfter + "##" `
+ "##" `
+ "cert.issuer=" + $_.Issuer `
+ "&cert.friendlyname=" + $_.FriendlyName `
+ "&cert.serialnumber=" + $_.SerialNumber `
+ "&cert.thumbprint=" + $_.Thumbprint `
+ "&cert.days=" + ($_.NotAfter - [datetime]::Today).Days `
+ "&cert.issuerby=" + (($_.Issuer -split ",") |? {$_ -like "CN=*"}) -replace "CN=" `
} `
| Format-Table -HideTableHeaders
----=================================================================================================----
Thanks,
Dom
Dominique
OP5 years agoFor the auto.cert.days appears in the info but the calculation by "{($_.NotAfter - [datetime]::Today).Days}" remains as text not change as value !!!!
For the auto.cert.issuerby still not appearing in the info and as it was in before the "days" it might be an issue with the name ... uppercase/lowercase... syntax!!!
LM User
·5 years agoIf you're making changes to the DS, you need to manually kick off discovery on the device to see the results right away (within a couple minutes).
Btw, adding auto.cert.days as a property is an alternative way of getting the data into a report (a resource inventory report).
Dominique
OP5 years agoAfter waiting an hour the auto.cert.days finally appears...
the field is in but the value if incorrect...
but still missing the auto.cert.idssuerby...
Dominique
OP5 years agoIt works for me in the Collector Attribute Script but does not work in the Active Discovery Script...
I don't get the field split available in my report or in the device info...
I tried also the days to expire and I have the same issue as well...
Dominique
OP5 years agoIt works for me in the Collector Attribute Script but does not work in the Active Discovery Script...
LM User
·5 years agoThe following works for me: