Hello Adam,

Could you please tell us what automation tools do you plan to implement?
What management tasks do you want to automate and how?

On Wed, Feb 28, 2018 at 2:28 AM, Adam Humpherys <a...@manwaringweb.com>
wrote:

> Odd. I went back to using just the basics:
>
> ps.AddCommand("Get-SvnRepository");
> Collection<PSObject> output = ps.Invoke();
>
> And now it's working. Initially, it told me it found the command in a
> module that hadn't been imported yet. But now it's working. So that's a bit
> weird.
>

The most likely reason why you are seeing the exception in the first
example is because the session created via *InitialSessionState.Create()*
does not include the definitions of the built-in commands (such as
*Export-ModuleMember*) which are required to successfully load and execute
commands from the CDXML module.

Could you please try the following code snippet that creates the session
using the InitialSessionState.CreateDefault() method that automatically
includes the necessary definitions for such built-ins?

    // Or InitialSessionState.CreateDefault2(), see
    // https://docs.microsoft.com/dotnet/api/system.management.auto
mation.runspaces.initialsessionstate.createdefault2
    var session = InitialSessionState.CreateDefault();
    session.ImportPSModule(new[] { "VisualSVN" });

    using (var runspace = RunspaceFactory.CreateRunspace(session))
    {
        runspace.Open();
        using (var invoker = new RunspaceInvoke(runspace))
        {
            var output = invoker.Invoke("Get-SvnRepository");
        }
    }

On Tuesday, February 27, 2018 at 2:21:10 PM UTC-7, Adam Humpherys wrote:
>>
>> I found one old message (from 2008) that asked for an API And I'm curious
>> if this is in consideration.
>>
>> We're building some automation tools to free up some developer time for
>> managing SVN repositories in VisualSVN. I've been trying to use the
>> PowerShell cmdlets from within a Windows service but it's not working very
>> well.
>>
>> But maybe if I can figure out what's wrong with the PowerShell execution
>> then that will be good enough.
>>
>>
>> using (PowerShell ps = PowerShell.Create())
>> {
>>     var psSession = InitialSessionState.Create();
>>     psSession.ImportPSModule(new string[] { "VisualSVN" });
>>     var ps_rSpace = RunspaceFactory.CreateRunspace(psSession);
>>     ps_rSpace.Open();
>>     var ps_invoker = new RunspaceInvoke(ps_rSpace);
>>
>>     Collection<PSObject> output = ps_invoker.Invoke("Get-SvnRepository");
>> }
>>
>> at ps_rSpace.Open() I get an error:
>>
>> Cannot process Cmdlet Definition XML for the following file: C:\Program
>> Files\VisualSVN Server\PowerShellModules\VisualSVN\SvnRepository.cdxml.
>> Value cannot be null.
>> Parameter name: key ---> System.Xml.XmlException: Cannot process Cmdlet
>> Definition XML for the following file: C:\Program Files\VisualSVN
>> Server\PowerShellModules\VisualSVN\SvnRepository.cdxml. Value cannot be
>> null.
>> Parameter name: key ---> System.ArgumentNullException: Value cannot be
>> null.
>>
>> I just upgraded to VisualSVN Server 3.8.0.
>>
>> The Windows service will have a web interface/rest api so we can hook up
>> our dashboard to it. Any ideas?
>>
>


--
With best regards,
Pavel Lyalyakin
VisualSVN Team

-- 
You received this message because you are subscribed to the Google Groups 
"VisualSVN" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to visualsvn+unsubscr...@googlegroups.com.
To post to this group, send email to visualsvn@googlegroups.com.
Visit this group at https://groups.google.com/group/visualsvn.
For more options, visit https://groups.google.com/d/optout.

Reply via email to