question

47451047 avatar image
0 Votes"
47451047 asked

PowerShell and .NET?

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

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

0 Answers