|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:46 AM
Points: 257,
Visits: 671
|
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 6:17 AM
Points: 1,625,
Visits: 1,926
|
|
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:46 AM
Points: 257,
Visits: 671
|
|
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
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 6:17 AM
Points: 1,625,
Visits: 1,926
|
|
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:46 AM
Points: 257,
Visits: 671
|
|
Please post the contents of your sqlem.ps1 file
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 6:17 AM
Points: 1,625,
Visits: 1,926
|
|
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.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:46 AM
Points: 257,
Visits: 671
|
|
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.
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Thursday, November 15, 2012 3:53 AM
Points: 2,
Visits: 63
|
|
| Does anyone know if its possible to do this without ps as I'm not allowed to run any ps scripts in my environment.
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, May 16, 2013 5:46 AM
Points: 257,
Visits: 671
|
|
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; }
|
|
|
|