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

88
Views
Powershell genera System.Type fuera de String

Estoy generando dinámicamente objetos .net de cierto tipo como este $MyType=([System.Type]::GetType("System.String") Esto funciona bien para objetos .net estándar.

Ahora creé una clase personalizada como esta

 class InstanceName { [String] hidden $Val InstanceName([String]$CVal) { $this.Val=$CVal } }

Aquí, este método no funciona porque PowerShell no puede encontrar el tipo. $MyType=([System.Type]::GetType("InstanceName")

¿Alguna idea de cómo puedo obtener un System.Type de una clase PS personalizada?

¡Gracias!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Utilice el operador de conversión de tipo -as :

 $instanceNameType = 'InstanceName' -as [type] # test the type reference $instanceNameType::new("")
over 4 years ago · Santiago Trujillo Report
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!