Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

337
Views
PowerShell conversion of String into FileInfo automatically - What is this called?

Some sample code to illustrate what I'm talking about. I've got a utility class with a single method. That method takes one argument: a System.IO.FileInfo object. From the PowerShell side I can pass in a System.String object and everything "just works". I'm curious as a develop getting more into PowerShell this year I'm curious:

  1. What feature of PowerShell allows this to happen?
  2. Is this open to extension / use by any developer in PowerShell 7.x? (non-internal)

C#:

using System.IO;
using System.Linq;

namespace TestProject
{
    public class Utility
    {
        public string GetFirstLine(FileInfo fileInfo)
        {
            string firstLine = File.ReadLines(fileInfo.FullName).First();
            return firstLine;
        }
    }
}

PowerShell:

Add-Type -Path "C:\assemblies\TestProject.dll"
$util = [TestProject.Utility]::New()
$util.GetFirstLine("C:\temp\random-log.txt")

Note: I realize this is trivial example. Code is meant for quickly illustrating the capability in PowerShell I am interested in.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!