title: Powershell - Set Version and company name of executable created by Powershell
body: <p>I am developing a <code>.ps1</code> powershell script which creates <code>.exe</code> file following this <a href="https://docs.microsoft.com/en-us/archive/msdn-magazine/2016/may/windows-powershell-writing-windows-services-in-powershell" rel="nofollow noreferrer">guide</a>. I have created <code>.exe</code> successfully. Here is a minimal example of the code.</p>
  <pre><code>[CmdletBinding(DefaultParameterSetName='Status')]
  Param(
    [Parameter(ParameterSetName='Start', Mandatory=$true)]
    [Switch]$Start,               # Start the service
  
    [Parameter(ParameterSetName='Stop', Mandatory=$true)]
    [Switch]$Stop,                # Stop the service
  )
  
  $scriptVersion = &quot;1.2.3.4&quot;
  $serviceName = Get-Item $MyInvocation.MyCommand.Definition     # myService
  $exeFullName = &quot;MyService.exe&quot;
  
  #  Source Code
  $source = @&quot;
    using System;
  
    public class Service_$serviceName : ServiceBase {
  
      public static void Main() {
        System.ServiceProcess.ServiceBase.Run(new Service_$serviceName());
      }
    }
  &quot;@
  
  if ($Start) {                   # service started
    Write-Verbose &quot;Starting service $serviceName&quot;
    Start-Service $serviceName # Ask Service Control Manager to start it
    return
  }
  
  if ($Stop) {                    # service stopped
    Write-Verbose &quot;Stopping service $serviceName&quot;
    Stop-Service $serviceName # Ask Service Control Manager to stop it
    return
  }
  
  # Generate .EXE from the C# source embedded in script
  try {
  Write-Verbose &quot;Compiling $exeFullName&quot;
  Add-Type -TypeDefinition $source -Language CSharp -OutputAssembly $exeFullName -OutputType ConsoleApplication -ReferencedAssemblies &quot;System.ServiceProcess&quot; -Debug:$false
  } catch {
  $msg = $_.Exception.Message
  Write-error &quot;Failed to create the $exeFullName service stub. $msg&quot;
  exit 1
  }
  
  </code></pre>
  <p>Now I want to assign attributes to <code>.exe</code> file, like <code>Version</code>, <code>Publisher</code> etc. I have followed this <a href="https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assemblycompanyattribute?view=net-5.0" rel="nofollow noreferrer">guide</a> but I am unable to complete the task. I am using Inno setup to bundle this <code>.exe</code> in main exe file. These are the commands to bundle in Inno setup:</p>
  <pre><code>[Run]
  Filename: &quot;powershell.exe&quot;;Parameters: &quot;-ExecutionPolicy Bypass -File &quot;&quot;{app}\myScript.ps1&quot;&quot; -setup&quot;; WorkingDir: {app}; Flags: runhidden
  Filename: &quot;powershell.exe&quot;;Parameters: &quot;-ExecutionPolicy Bypass -File &quot;&quot;{app}\myScript.ps1&quot;&quot; -start&quot;; WorkingDir: {app}; Flags: runhidden
  
  </code></pre>
  <p>Any help is appreciated. Thanks !</p>