Steffen,
I've never created a snapin, about the time I started getting interested in
Powershell v2 was released as a CTP and modules at least to my understanding
have replaced snapin's any case thats the route I went.
Perhaps someone that has a better understanding of snapins can help.
Here is what I understand
PC B : Client-App => PC A: WFC service (Add's and uses your snapin)
The WFC service is most likely running under the credentials of
"NetworkService" and I wouldn't recomend changing it _except_ possible to
verify if that's the problem.
This account is limited on purpose I suspect the reason for the exception
(BTW what is the exception being thrown?) is because AddSnapin requires more
priviledges than this account is capabile of.
If this does turn out to be the issue you will need to add the snapin by
impersonating an account that has these priviledges and then revert back to
the process account since you will want this service running with the mimimal
priviledges that are required.
"Steffen Mangold" wrote:
> Hi Bob,
> sorry if i not clear.
>
> PC A -> CmdLet -> WCF
> PC B -> Client App.
>
> PC B call the WCF Service on PC A
> The PC A called the CmDLet and returnd a Result
>
> The exception is thrown on AddPSSnapIn call.
> On PC A i tested the CmdLet manuall, it is installed and work fine.
>
> But if PC B called the WCF and the WCF methode try to add the Snapin it fail.
>
> "Bob Landau" wrote:
>
> > At least for me your description below isn't clear.
> >
> > You have to machines A and B.
> >
> > Can you use your snapin on both machines directly?
> > Can you use your snapin on any machine if its called with the WCF service?
> >
> > On whatever machine which the snapin is not working, have you first
> > registered the snapin?
> >
> > What line of code is throwing the exception?
> >
> > "Steffen Mangold" wrote:
> >
> > > Hi, i have a question.
> > >
> > > I developt a PSCommandLet and install it ob a PC. When i call it from the PC
> > > all works fine.
> > >
> > > Now i write a WCF Service with some methods and they methods call some of my
> > > powershell CmdLets. When i now run a client on a other PC and call the WCF
> > > Service methods i always get an exception that my powershell-snap-in is not
> > > installed on the PC. Why it works local but not if an client call the WCF
> > > Service and the service call the PS??? 
> > >
> > > Here my code:
> > >
> > > RunspaceConfiguration config = RunspaceConfiguration.Create();
> > >
> > >
> > > Runspace runspace = RunspaceFactory.CreateRunspace();
> > >
> > > runspace.Open();
> > >
> > > PSSnapInException ex = new PSSnapInException();
> > >
> > > runspace.RunspaceConfiguration.AddPSSnapIn("SunvoltEnergyStudioPowerShell",
> > > out ex);
> > >
> > > Collection<Project> projects = new Collection<Project>();
> > > Pipeline getProjectsPipeline = runspace.CreatePipeline();
> > > getProjectsPipeline.Commands.Add(new Command("Get-Projects"));
> > > Collection<PSObject> results = getProjectsPipeline.Invoke();
> > >
> > >