Mam naprawdę prosty skrypt powłoki (zobacz poniżej). Mam installutil alias za pomocą następujących w moim profilu:C# Powershell snapin nie rejestruje się przy użyciu installutil
set-alias installutil $env:windir\Microsoft.NET\Framework\v2.0.50727\installutil
PowerShell po prostu:
installutil assemplylocation.dll
ta zwraca pomyślnie. (Instaluj/Zatwierdź oba zakończono pomyślnie). Jednak po sprawdzeniu rejestru lub w trybie powershell za pomocą polecenia get-pssnapin - nie jest wyświetlane moje złożenie. Zrobiłem to drugi dzień i wszystko działało dobrze, ale wydaje mi się, że nie mogę go powielić ... proszę o radę.
using System;
using System.Management.Automation;
using System.ComponentModel;
namespace PSBook_2_1
{
[RunInstaller(true)]
public class PSBookChapter2MySnapIn : PSSnapIn
{
public PSBookChapter2MySnapIn()
: base()
{ }
// Name for the PowerShell snap-in.
public override string Name
{
get
{
return "Wiley.PSProfessional.Chapter2";
}
}
// Vendor information for the PowerShell snap-in.
public override string Vendor
{
get
{
return "Wiley";
}
}
// Description of the PowerShell snap-in
public override string Description
{
get
{
return "This is a sample PowerShell snap-in";
}
}
}
// Code to implement cmdlet Write-Hi
[Cmdlet(VerbsCommunications.Write, "Hi")]
public class SayHi : Cmdlet
{
protected override void ProcessRecord()
{
WriteObject("Hi, World!");
}
}
// Code to implement cmdlet Write-Hello
[Cmdlet(VerbsCommunications.Write, "Hello")]
public class SayHello : Cmdlet
{
protected override void ProcessRecord()
{
WriteObject("Hello, World!");
}
}
}
Problem był z tym systemem w wersji 32-bitowej z PowerShell, zamiast 64- bit ... – downatone