VictorGh

updated

3 years ago

Closed

V

VictorGh

1 Rookie

•

35 Posts

0

960

May 4th, 2023 10:00

Creating a multi lines Directive with Powershell

Networker Server 19.3

I am trying to create a Directive with multiple lines from a Powershell script

For example, I'd like it to contain the following lines:

<< "c:\temp" >>
skip: *

<< / >>
+compressasm: .

I had partial success, I created a txt file (directive.txt) with the following content:

create type: NSR directive; name:SkipTemp;directive: << "\"c:\\temp"\" >> "skip: *"

I then called it from powershell like this:

cmd.exe /c "nsradmin -i .\src\directive.txt"

It worked, the directive was created, however everything in the directive is on a single line, I need to script a directive with 10 lines and not sure how to achieve it.

Any advice will be appreciated!

 

  • 746

    0

    Posted May 4th, 2023 12:00

    Your directive.txt does not show here that it contains even multiple entries, it only states one? On a Linux NW server I'd add a directive via an input file similarly. My input file contains enters at the end of each line.

    As you can see I leave out various quotes that you use.

    However I don't ever work from Windows. Only Linux backup servers.

    user@server:~> cat test_directive.nsri
    create type: NSR directive;
    name: test;
    comment: "test directive";
    directive: \
    "<< \"E:\\\" >>
    +skip: *.*
    << \"F:\\\" >>
    +skip: *.*
    << \"G:\\\" >>
    +skip: *.*
    << \"H:\\\" >>
    +skip: *.*
    << \"I:\\\" >>
    +skip: *.*";
    user@server:~> nsradmin -i test_directive.nsri
    created resource id 52.0.21.115.0.0.0.0.112.36.229.99.x.x.x.x(1)
    user@server:~> nsradmin
    NetWorker administration program.
    Use the "help" command for help, "visual" for full-screen mode.
    nsradmin> . type:nsr directive;name:test
    Current query set
    nsradmin> pr
    type: NSR directive;
    name: test;
    comment: test directive;
    directive: \
    "<< \"E:\\\" >>
    +skip: *.*
    << \"F:\\\" >>
    +skip: *.*
    << \"G:\\\" >>
    +skip: *.*
    << \"H:\\\" >>
    +skip: *.*
    << \"I:\\\" >>
    +skip: *.*";
    restricted data zone: ;
    nsradmin> q
    user@server:~>


     

  • VictorGh

    1 Rookie

    •

    35 Posts

    747

    0

    Posted May 4th, 2023 12:00

    I found the answer, the directive.txt need to contain the following (with an empty new line at the very end):

    create type: NSR directive; name:SkipTemp2;directive:"
    << \"c:\\temp\" >>
    skip: *

    << / >>
    +compressasm: .
    ";

  • VictorGh

    1 Rookie

    •

    35 Posts

    739

    0

    Posted May 4th, 2023 14:00

    That worked like a charm, thank you !!