Any help is appreciated.
I am trying to run the following PS code within VBA and return the value for $email and $FASCN argument to an Excel worksheet.
$myEDIPI = (whoami /upn).replace('@mil','')
$comOBJS = @()
$PIVCERT = gci Cert:\CurrentUser\My | ? {$_.Subject -like "*$($myEDIPI)*" -and $_.FriendlyName -like "Authentication -*" -and $_.HasPrivateKey -eq $true}
$EMAILCERT = gci Cert:\CurrentUser\My | ? {$_.Subject -like "*$($myEDIPI)*" -and $_.FriendlyName -like "Signature -*" -and $_.HasPrivateKey -eq $true}
$Extensions=$pivcert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Subject Alternative Name"}
$EmailAddress=$EMAILCERT.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Subject Alternative Name"}
$comOBJS += new-object -ComObject X509Enrollment.CX509ExtensionAlternativeNames
$comOBJS += new-object -ComObject X509Enrollment.CX509ExtensionAlternativeNames
$FASCNString=[System.Convert]::ToBase64String($Extensions.RawData)
$emailString=[System.Convert]::ToBase64String($EmailAddress.RawData)
$comObjs[0].InitializeDecode(1, $FASCNString)
$FASCN = ($comOBJS[0].AlternativeNames | ?{$_.StrValue -like "*$($myEDIPI)*"} ).strvalue
$comOBJS[1].InitializeDecode(1, $emailString)
$email = ($comOBJS[1].AlternativeNames | ?{$_.StrValue -like "*@mail.mil"}).strvalue
write-host "FASCN discovered: " $FASCN
write-host "Email discovered: " $email
I am trying to run the following PS code within VBA and return the value for $email and $FASCN argument to an Excel worksheet.
$myEDIPI = (whoami /upn).replace('@mil','')
$comOBJS = @()
$PIVCERT = gci Cert:\CurrentUser\My | ? {$_.Subject -like "*$($myEDIPI)*" -and $_.FriendlyName -like "Authentication -*" -and $_.HasPrivateKey -eq $true}
$EMAILCERT = gci Cert:\CurrentUser\My | ? {$_.Subject -like "*$($myEDIPI)*" -and $_.FriendlyName -like "Signature -*" -and $_.HasPrivateKey -eq $true}
$Extensions=$pivcert.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Subject Alternative Name"}
$EmailAddress=$EMAILCERT.Extensions | Where-Object {$_.Oid.FriendlyName -eq "Subject Alternative Name"}
$comOBJS += new-object -ComObject X509Enrollment.CX509ExtensionAlternativeNames
$comOBJS += new-object -ComObject X509Enrollment.CX509ExtensionAlternativeNames
$FASCNString=[System.Convert]::ToBase64String($Extensions.RawData)
$emailString=[System.Convert]::ToBase64String($EmailAddress.RawData)
$comObjs[0].InitializeDecode(1, $FASCNString)
$FASCN = ($comOBJS[0].AlternativeNames | ?{$_.StrValue -like "*$($myEDIPI)*"} ).strvalue
$comOBJS[1].InitializeDecode(1, $emailString)
$email = ($comOBJS[1].AlternativeNames | ?{$_.StrValue -like "*@mail.mil"}).strvalue
write-host "FASCN discovered: " $FASCN
write-host "Email discovered: " $email
Last edited: