Import/Export SQL Server 2000 Enterprise Manager Registered Servers

  • cmille19

    SSCertifiable

    Points: 5920

    Comments posted to this topic are about the item Import/Export SQL Server 2000 Enterprise Manager Registered Servers

  • MG-148046

    SSCrazy Eights

    Points: 9942

    I'm a newbie with PS. I get as far as sourcing the script but have no idea of what to do next.

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • cmille19

    SSCertifiable

    Points: 5920

    You once you've sourced the file

    PS> . ./sqlem.ps1

    You should be able to simply run the functions the Powershell script defines:

    Export-RegisteredServers c:\servers.txt

    or

    Import-RegisteredServers c:\servers.txt

  • MG-148046

    SSCrazy Eights

    Points: 9942

    Doesn't work for me and I set execution to unrestricted. see attachment

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • cmille19

    SSCertifiable

    Points: 5920

    Please post the contents of your sqlem.ps1 file

  • MG-148046

    SSCrazy Eights

    Points: 9942

    It seems that the article had some unprintable characters that PS didn't like. I put the code into an editor I have that shows control codes and found them. Removed them and it all works like a charm! 🙂 Thanks

    MG

    "There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies."
    Tony Hoare

    "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.

  • cmille19

    SSCertifiable

    Points: 5920

    I noticed the same thing, I'll follow up with the site owners, as it appears be a problem with their script editor. I'm able to reproduce an issue where multiple "?" characters appear when copying the code. It doesn't seem to matter whether I manually create the code with their editor or copy it from notepad. Perhaps it doesn't like some of the special characters (#, %, ?) used in Powershell.

  • AndrewL65

    Mr or Mrs. 500

    Points: 523

    Does anyone know if its possible to do this without ps as I'm not allowed to run any ps scripts in my environment.

  • cmille19

    SSCertifiable

    Points: 5920

    It could be done in VBScript or Perl. Here's an old Perl script. I can't find old VBScript:

    #Perl Script based on

    #http://www.sqlservercentral.com/scripts/contributions/1467.asp

    use strict;

    use Getopt::Std;

    use Win32::OLE;

    use Win32::OLE::Const("Microsoft SQLDMO");

    my (%args, $args, $serverfile, $groupname, $servername, $ServerGroup, $cnt);

    my $err = 0;

    my $SQLServer = new Win32::OLE 'SQLDMO.SQLServer';

    my $Application = $SQLServer->{Application};

    getopts('f:', \%args);

    $serverfile = $args{f};

    $cnt = 0;

    open SERVERFILE, $serverfile or die "Cannot open file: $serverfile";

    while (<SERVERFILE>)

    {

    print "Processing $_";

    s/#.*//; # remove comments, ignore blank lines

    if (!$_) {next;}

    tr/\t / /s;

    $cnt++;

    ($groupname, $servername) = split;

    $ServerGroup = new Win32::OLE 'SQLDMO.ServerGroup';

    $ServerGroup = CreateGroup($groupname);

    RegisterServer($ServerGroup, $servername);

    $ServerGroup = undef;

    $servername = undef;

    }

    close SERVERFILE;

    exit $err;

    sub CreateGroup

    {

    my $ServerGroup = new Win32::OLE 'SQLDMO.ServerGroup';

    $ServerGroup->{Name} = $groupname;

    $Application->ServerGroups->Add($ServerGroup);

    $ServerGroup = undef;

    $ServerGroup = $Application->ServerGroups->Item($groupname);

    return $ServerGroup;

    }

    sub RegisterServer

    {

    my $RegisteredServer = new Win32::OLE 'SQLDMO.RegisteredServer';

    $RegisteredServer->{Name} = $servername;

    $RegisteredServer->{UseTrustedConnection} = 1;

    $RegisteredServer->{PersistFlags} = 1;

    $ServerGroup->RegisteredServers->Add($RegisteredServer);

    $RegisteredServer = undef;

    }

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply