February 19, 2008 at 2:30 am
Comments posted to this topic are about the item Import/Export SQL Server 2000 Enterprise Manager Registered Servers
April 24, 2008 at 11:05 am
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.
April 24, 2008 at 12:40 pm
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
April 24, 2008 at 12:51 pm
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.
April 24, 2008 at 8:07 pm
Please post the contents of your sqlem.ps1 file
April 25, 2008 at 5:55 am
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.
April 25, 2008 at 6:48 am
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.
September 28, 2011 at 5:56 am
Does anyone know if its possible to do this without ps as I'm not allowed to run any ps scripts in my environment.
September 28, 2011 at 9:47 am
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 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply