Hello. I had the task to get the data from the certificate. They helped me and gave me a code:
#requires -version 7
$GetDNComponents = [DirectoryServices.SortOption].Assembly.GetType(
'System.DirectoryServices.ActiveDirectory.Utils'
).GetMethod(
'GetDNComponents', [Reflection.BindingFlags]'NonPublic, Static'
)
(Get-ChildItem cert:\CurrentUser\My).Subject.ForEach{
$GetDNComponents.Invoke($null, @($_)).Where{
$_.Name -in 'CN', 'E', 'SN'
}.ForEach{
Set-Variable -Name $_.Name -Value $_.Value
}
}
I couldn't find information on where these functions came from.
Am I correct in assuming that PowerShell works with the NET Framework module and the function above is from it, but just not added to the PowerShell module?
But since PowerShell works with the NET Framework, we can convert its functions to PowerShell?
Where to read about it, how to know all the functions, how to convert them to PowerShell?
UPD: I think I found this class, but I don't understand its syntax and how it was converted to PowerShell.
https://referencesource.microsoft.com/#System.DirectoryServices/System/DirectoryServices/SortOption.cs,040e5b60ce35a1fc