I have a PowerShell script that uses Add-Type and for -TypeDefinition I would like to, instead of defining $Source = @""@, define $Source = script.cs.
Is this possible and if so how does one go about doing it?
$Source = Get-Content -Path $PSScriptRoot\script.cs -Raw
Add-Type -ReferencedAssemblies 'System', 'System.Runtime.InteropServices' -TypeDefinition $Source -Language CSharp
Then I use whatever in C# script later on in the PS script. I do believe these are the only two important area right now
$Source = Get-Content $PSScriptRoot\script.cs -Raw-- assuming "script.cs" is located in the same folder as the PoSh script.