Powershell to get instance name

Hi,
Not sure whether this is the forum to ask.I have a list of servers names and i need to get the instance names in below format.
SERVERNAME\INSTANCE1
The o/p of the script actually shows Servername,MSSQL$Instance name..Anyway to tweak this to SERVERNAME\INSTANCE1?
$servers = get-content "C:\SQLCheck\machinelist.txt"
$logfile = "C:\SQLCheck\sql-instances.txt"
$logerrs = "C:\SQLCheck\sql-failures.txt"
Echo "Server, Instance" >> $logfile
ForEach ($server in $servers) {
$instances = Get-WmiObject -ComputerName $server win32_service | where {$_.name -like "MSSQL*"}
if (!$?) {
Echo "$server - No SQL instance found" >> $logerrs
Echo "$server - No SQL instance found"
Else {
ForEach ($instance in $instances) {
if (($instance.name -eq "MSSQLSERVER") -or ($instance.name -like "MSSQL$*")) {
Echo "$server\$instance.name" >> $logfile
Echo "$server, $($instance.name)"
Best Regards, Arun http://whynotsql.blogspot.com/

Hi,
Use the sqlcmd -L command:
$SqlCmd = "sqlcmd -L "
Invoke-Expression $SqlCmd
sqlcmd Utility
http://technet.microsoft.com/en-us/library/ms162773.aspx
Thanks.
Tracy Cai
TechNet Community Support

Similar Messages

  • How to get instance name

    I was wondering if there was any way to get the instance name
    of the class to the class without having to pass it in when you
    create the instance of it. For example, so I can do this:
    var myObject:CustomClass = new CustomClass();
    and then the class knows whats its instance name being used
    is instead of having to do something like this:
    var myObject:CustomClass = new
    CustomClass("myObject");

    As I think I found out how to gnerate unique key form components passed to my method and afterwards be able to get this key by knowing the component.My code is following:
    public static String generateUniqueKey(Component c){
    String resultString="";
    String s = c.getAccessibleContext().getAccessibleComponent().toString();
    StringBuffer stringbuffer = new StringBuffer(s);
    if(!Character.isJavaIdentifierStart(stringbuffer.charAt(0))){
    resultString="a_";
    }else{
    resultString=resultString+stringbuffer.charAt(0);
    for(int j = 1; j < s.length(); j++){
    if(!Character.isJavaIdentifierPart(stringbuffer.charAt(j))){
    resultString=resultString+"_";
    }else{
    if (stringbuffer.charAt(j)=='$'){
    resultString=resultString+"s_";
    }else{
    resultString=resultString+stringbuffer.charAt(j);
    return resultString;
    Any suggestions on this. May this result in problems anywhere?
    Thanks

  • Flash CC HTML5 Get instance names on click?

    I make escape games and often have lots of items in a scene each with flash instance names that on mouse over or mouse click make some event happen or some text is displayed.
    I'm using Flash CC and HTML 5 output and cannot get it to output the instance names in the log, is this not possible? Can anyone suggest an alternative method of responding to lots of movieclips/buttons etc
    Here's my test code:-
    //stage.enableMouseOver(24);
    var clicked = "";
    var clickedname = "";
    //NEED TO FIND OUT MOVIECLIP INSTANCE NAME??
    var key1 = exportRoot.key1
    //key1.name = "key1"
    //console.log(key1ref.name)
    stage.on("click", function (evt) {
        //clickedname = stage.getObjectUnderPoint(evt.stageX, evt.stageY)
        //clicked = evt.target
        clicked = evt.target
        console.log(clicked)
        //output result to log
        /*if (clicked == "key1"){
            console.log("clicked key 1")

    Thanks Ned, I really appreciate the help as I've been stuck on this seemingly obvious thing for a few days now and can't progress until I can figure it out...
    Basically using currentTarget it outputs this:-
    a {id: 24, _matrix: a, _rectangle: a, children: Array[1], canvas: canvas#canvas…}
    so comparing it to a name/instance name is not going to work ;-)
    using evt.target gets me this:-
    lib.key1 {id: 21, _matrix: a, _rectangle: a, image: img, x: -40…}
    so again useless, a reference to the key1.png in the library but not to the named instances placed on the stage!!
    Am I assigning the instance name correctly??
    var key1 = exportRoot.key1
    key1.name = "key1"
    Any help from anyone appreciated!!

  • Get instance name help

    Okay, I want to be able to click anywhere and get the
    instance name of any object. The kicker is this actionScript needs
    to be on the main timeline and not on the movieClip. In other
    words, if I have one movieClip on the stage named "my_MC". I want
    to be able to run the movie and when I click on the stage it will
    trace "_level10", but when I click on the first movieClip, it will
    trace its instance name "my_MC".
    I know that:
    this.onMouseDown = function() {
    trace(this);
    will give me the instance name of the stage or "_level10",
    but how do I make it identify the movieClip I'm clicking on without
    putting any script on the movieClip itself?

    You need to do something like this, since the generic parameters don't exist at runtime.
    public M createMInstance(Class <? extends M> clazz) {
      return clazz.newInstance();
    }I'm not very well versed in generics, so you may have to tweak it a bit, but the main idea is that you have to provide the Class object.

  • Tween and getting instance names problems

    Hi, iv got these buttons animated using the inbuilt tween
    function and am coding them like this:
    function navOver(e:MouseEvent):void {
    var page = MovieClip(e.currentTarget).buttonThumb;
    var myTween16:Tween = new Tween(page, "y", Regular.easeOut,
    0, -25, 0.35, true);
    function navOut(e:MouseEvent):void {
    var page = MovieClip(e.currentTarget).buttonThumb;
    var myTween17:Tween = new Tween(page, "y", Regular.easeOut,
    -25, 0, 0.35, true);
    function navClick(e:MouseEvent):void {
    var page = MovieClip(e.currentTarget).buttonThumb;
    page.y = 0;
    button.addEventListener(MouseEvent.ROLL_OVER, navOver);
    button.addEventListener(MouseEvent.ROLL_OUT, navOut);
    button.addEventListener(MouseEvent.MOUSE_DOWN, navClick);
    but if i click on the button before the animation has
    finished it ignores the
    page.y = 0; code and does nothing. how can i fix this?
    also im trying to get the instance name of a mc called
    "home" using this code:
    MovieClip(e.currentTarget) wich gives me the result
    [object button_1]
    and
    MovieClip(e.currentTarget).instanceName returns
    undefined
    neather of which are the instance name.
    i cant hardcode the function because its used on lots of
    different mcs throughtout the flash file
    thanks

    if you want to send the 'page' back to the 0 position, you
    might be better off declaring the tweens outside the method, in
    this way you can control them in 'other' methods that aren't local
    to where the assignment is made, for instance:
    var myTween17:Tween;
    then in the handler navOut, just 'assign' the tween:
    myTween17 = new Tween( .. );
    then in the navClick method you could call:
    myTween17.stop();
    myTween17.rewind();
    and that should reset the clips position to 0
    for your other question use:
    MovieClip(e.currentTarget.name);

  • Get instance name

    Hello
    Is there any dynamic way to obtain an object's instance (variable) name?
    For example:
    Object myObject = new Object();
    System.out.println( "The object's name is: " + someMethod() );
    And the output would be:
    The object's name is: myObject
    Thanks in advance.

    Even if it were possible...import  java.lang.reflect.*;import java.util.*;
    public class VariableNames {
    static Object obj = new Object();
    static Object obj2 = obj;
    static Object obj3 = obj2; //-- a single Object referred to by 3 variables
    public static void main (String[] args) {
    System.out.println(getTheNamesOfTheVariablesThatReferToThisObject(obj3));
    //-- it has to print the list {obj, obj2, obj3}.
    public static List getTheNamesOfTheVariablesThatReferToThisObject (Object obj) {
    List varnames = new ArrayList();
    Class clazz = VariableNames.class;
    Field[] fields = clazz.getDeclaredFields();
    for (int index=0, length=fields.length; index<length; index++) {
    try {
    if (fields[index].get(null) == obj) {
    varnames.add(fields[index].getName());
    } catch (IllegalAccessException e) {
    // ignore
    return varnames;
    }Of course, if you tell us why you would want to do this, then there is probably a better solution (except for some types of constriant programming, where it can be justified) Pete

  • Get current SQL instance name with PowerShell

    Hi all,
    I'm preparing SQL agent job that will backup all jobs on SQL server. Main step is PoswerShell script. I want that job to be universal for all servers. The first parameter that I need to send to script is instancename.
    I want to use variable as InctanceName parameter. So, when I run this job on particular server this variable must get current SQL instance name.
    I can use $env:computername for default instances but I cannot use it with named instances or with clustered instances. Some solutions like using 'HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL' keys won't work because of number of
    instanses can be running on one machine.
    How to get only current SQL instance name?

    Hi, 
    Thank you for your answers.
    I found this solution:
    $serverInstance = "$(ESCAPE_DQUOTE(SRVR))"
    Working perfect.

  • Stored procedure for getting host name, host instance and status of that host is it running or stopped.

    Hello all,
    yesterday I got one task in that I have to stored procedure for getting host name, host instance and status of that host is it running or stopped.
    any body knows where exactly, In which table this details are there in BizTalk databases.
    thanks

    Status of the host instance is not stored in the SQL database for you to query the status using stored procedure. You have to either use Powershell or WMI to get the status.
    In SQL, following table contains the details about the host like Name, LoginName, IsDisables etc but status of the host instance is not stored in the database.
    SELECT * FROM BizTalkMgmtDb..adm_HostInstance
    Powershell to get the status:
    http://axonolympus.nl/?page_id=186&post_id=969&cat_id=6&lang=en
    WMI to get the status:
    https://msdn.microsoft.com/en-us/library/aa561820.aspx?f=255&MSPPError=-2147217396
    https://msdn.microsoft.com/en-us/library/aa578621.aspx
    Regards,
    M.R.Ashwin Prabhu
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • How to get DB Instance name

    Hi ,
    I have build a solutuon to send email invoce using BIP.
    I want to prefix the DB instance name in email Subject on development/test instances.
    Please suggest me how to get the DB name in BI publisher bursting control file.
    <xapi:message id="1" to="${TO_EMAIL_ID}" attachment="true" content-type="html/text" subject="$
    for exmaple: I have email with
    subject: 74444555 - Invoice(20071429) notification
    on my development box icprj01 I need email subject like
    subject: ICPRJ01 74444555 - Invoice(20071429) notification
    Thanks
    Kumar

    Can't do it in bursting. You will need to pull the db name for sql in a data template or reports6i. Sorry :-(

  • How to get object/instance name in method

    Hi folks,
    I have created a class and implemented a method within the class.
    Now i would like get the name of instance/object calling this method ,within this method.
    Is their any way to get this obj name within method?
    Eg:
    I hve class ZCL with method METH
    Now in some program i used this method, by creating any obj
              data obj type ref to ZCL
              obj->METH
    Now is there any way to get this obj name within the methodMETH by using some method like GET_OBJ_NAME(just making a guess)
    Regards
    PG

    >
    PG wrote:
    > Now is there any way to get this obj name within the methodMETH by using some method like GET_OBJ_NAME(just making a guess)
    >
    > Regards
    > PG
    Please check the below code snippet
      DATA:
        lref_obj TYPE REF TO cl_abap_typedescr.
      lref_obj ?= cl_abap_objectdescr=>describe_by_object_ref( me ).

  • Get server instance name without deploying weblogic.jar to client

    I use wlclient.jar with my client. Using weblogic.jar instead causes the
    size of the deployment package of my client to go from 4 meg to 34 meg
    (roughly). I don't want full MBean functionality, all I want to do is find
    out what the server instance name is. Surely there's a way to do this.

    Hi,
    Weblogic provides you a way to create client jar files so that the complete weblogic.jar
    doesn't need to be downloaded to the client. The tool is called verboseToZip.
    See
    http://e-docs.bea.com/wls/docs70/adminguide/utils.html#1117405
    hope this helps, pat
    "BEA" <[email protected]> wrote:
    I am trying to deploy my client application on a standalone windows machine
    and do not wish to deploy weblogic.jar with the client deployment. Is
    there
    any way of allowing my clients to use Weblogic JNDI without having to
    deploy
    weblogic.jndi.WLInitialContextFactory.class (and its associated classes.
    I find it hard to believe that everyone who is developing on weblogic
    distributes this JAR file to their customers with their client
    applications....?
    Can you use something other than weblogic.jndi.WLInitialContextFactory
    such
    as the sun jndi provider instead....?
    If anyone can shed some light on this deployment problem it would be
    much
    appreciated.....even if its simply 'thats just the way you have to do
    it
    !......will save me time trying to get other solutions to work...!
    TIA

  • How to get Host name and SQL Instance Name by T-SQL

    I am using SQL 2000, 2005 and 2008. I have few multi instances SQL servers. I would like to gather following information:
    Host Name
    SQL Instance Name
    SQL Version
    Server1
    Server1
    SQL 2000
    Server1
    Server1\ABC
    SQL 2005
    Server1
    Server1\XYZ
    SQL 2008
    Server2
    Server2
    SQL 2008
    Is there any way I can get it by T-SQL? Any help would be appreciated.
    Thanks
    Saumen 

    SELECT
    SERVERPROPERTY('MachineName') AS [ServerName],
    SERVERPROPERTY('ServerName') AS [ServerInstanceName],
    SERVERPROPERTY('InstanceName') AS [Instance],
    SERVERPROPERTY('Edition') AS [Edition],
    SERVERPROPERTY('ProductVersion') AS [ProductVersion],
    Left(@@Version, Charindex('-', @@version) - 2) As VersionName
     |
    Blog: MSBICOE.com |
    MCITP - BI, SQL Developer & DBA
    Hate to mislead others, if I'm wrong slap me. Thanks!

  • Get All instance names in the stage

    hi,
    is there any way to get all instance name of the objects presents on the stage ? trace them for example
    thank you

    thank you, it's the correct answer but i still can't solve my problem ,
    the thing is that am using a code from http://www.freeactionscript.com that make enemie follow the player, but i need to do some modification, i need to detect collision between enemies so they will not get the one into the other and the thing that i cannot found their instance name, even when i used your function i only get "player_mc : _level0.player_mc" at the output,
    here is the code, i will be really greatful if you can find a way to help me solve this problem .
    ps :
    am trying to write my own code that make enemie follow the player, coz this one looks very complicated
    thank you
    the code :
    * Game Enemy AI Behavior - Run Away & Follow Player
    * Version:           1.0
    * Author:           Philip Radvan
    * URL:                     http://www.freeactionscript.com
    var enemiesArray:Array = new Array();
    var radians:Number = 180/Math.PI;
    createEnemies(5, "typeA", "e1");
    createEnemies(5, "typeB", "e2");
    createEnemies(5, "typeC", "e3");
    // createEnemies(number of enemies, behavior)
    // use ex: createEnemies(10, "slow", "myLinkedMovieClip);
    function createEnemies(enemyAmount:Number, enemyBehavior:String, enemyLibraryClip:String):Void
              //run a for loop based on the amount of enemies
              for(var i = 0; i < enemyAmount; i++)
                        //set temporary variable that will hold the new enemy attributes
                        var tempEnemy:MovieClip = _root.attachMovie(enemyLibraryClip, "enemy"+_root.getNextHighestDepth(),_root.getNextHighestDepth())
                        //give new enemy a random x/y position based on stage width/height
                        tempEnemy._x = random(Stage.width);
                        tempEnemy._y = random(Stage.height);
                        tempEnemy._rotation = random(360);
                        //set enemy behavior
                        if(enemyBehavior == "typeA")
                                  //define enemy characteristics
                                  tempEnemy.speed = 1
                                  tempEnemy.turnRate = .05
                                  tempEnemy.agroRange = 200;
                                  tempEnemy.mode = "follow"
                        else if(enemyBehavior == "typeB")
                                  //define enemy characteristics
                                  tempEnemy.speed = 4
                                  tempEnemy.turnRate = .5
                                  tempEnemy.agroRange = 200;
                                  tempEnemy.mode = "follow"
                        else if(enemyBehavior == "typeC")
                                  //define enemy characteristics
                                  tempEnemy.speed = 1
                                  tempEnemy.turnRate = .2
                                  tempEnemy.agroRange = 100;
                                  tempEnemy.mode = "run"
                        //define variables that are used to calculate following
                        //*don't change these*
                        tempEnemy.distanceX = 0;
                        tempEnemy.distanceY = 0;
                        tempEnemy.distanceTotal = 0;
                        tempEnemy.moveDistanceX = 0;
                        tempEnemy.moveDistanceY = 0;
                        tempEnemy.moveX = 0;
                        tempEnemy.moveY = 0;
                        tempEnemy.totalmove = 0;
                        //add new enemy to array
                        enemiesArray.push(tempEnemy)
    //Update enemies function
    function updateEnemies():Void {
              //run a for loop based on the amount of enemies
              for(var i = 0; i < enemiesArray.length; i++)
                        //set temporary variable that will hold the new enemy attributes
                        var tempEnemy:MovieClip = enemiesArray[i];
                        //run follow function with temporary enemy as the follower
                        updatePosition(tempEnemy, player_mc);
    // updatePosition(follower, target)
    // use ex: updatePosition(myEnemyMovieClip, playerMovieClip)
    function updatePosition(follower:MovieClip, target:MovieClip) {
              //calculate distance between follower and target
              follower.distanceX = target._x-follower._x;
              follower.distanceY = target._y-follower._y;
              //get total distance as one number
              follower.distanceTotal = Math.sqrt(follower.distanceX * follower.distanceX + follower.distanceY * follower.distanceY);
              //check if target is within agro range
              if(follower.distanceTotal <= follower.agroRange){
                        //calculate how much to move
                        follower.moveDistanceX = follower.turnRate * follower.distanceX / follower.distanceTotal;
                        follower.moveDistanceY = follower.turnRate * follower.distanceY / follower.distanceTotal;
                        //increase current speed
                        follower.moveX += follower.moveDistanceX;
                        follower.moveY += follower.moveDistanceY;
                        //get total move distance
                        follower.totalmove = Math.sqrt(follower.moveX * follower.moveX + follower.moveY * follower.moveY);
                        //apply easing
                        follower.moveX = follower.speed * follower.moveX / follower.totalmove;
                        follower.moveY = follower.speed * follower.moveY / follower.totalmove;
                        //move & rotate follower
                        if(follower.mode == "follow")
                                  follower._x += follower.moveX;
                                  follower._y += follower.moveY;
                                  follower._rotation = Math.atan2(follower.moveY, follower.moveX) * radians;
                        else if(follower.mode == "run")
                                  follower._x -= follower.moveX;
                                  follower._y -= follower.moveY;
                                  follower._rotation = (Math.atan2(follower.moveY, follower.moveX) * radians)+180;
    //onEnterFrame that executes the updatePosition updateEnemies every frame
    _root.onEnterFrame = function(){
              updateEnemies();
    //start/stop drag for player_mc
    player_mc.onPress = function(){
              startDrag(this);
    player_mc.onRelease = function(){
              stopDrag();

  • Get the instance names of clips attached to a movieclip

    I want to get the instance names of all the cmovieclips that
    are attached to a movieclip.
    Is there a simple way to do this.
    I imagine this is something that can be done with AS3 but can
    it be done with AS2?
    regards J

    you're welcome.
    FYI: a for...in loop loops through all the accesible
    properties (in the broadest sense of the meaning, includes
    methods/functions and variables etc). Each time it finds one it (in
    this case) assigns the property name to the variable 'unknown'
    the code inside the loop just checks
    a) is it a property that references a movieclip instance and
    b) is it the same property name as the movieclip instance's
    _name property (this is to avoid listing additional references to
    the same movieclip instance that may be set up as variables in your
    McA's scope).
    I just read that and I'm wondering if it actually will help
    you understand... its quite complicated to describe,sorry...
    although its simple to understand once you get used to it. To learn
    you should experiment with a few for.. in loops on different
    objects and see what trace outputs you get.

  • Get weblogic instance name in cluster env.

              Hi, there, how can I get each weblogic instance name in cluster env. in my code?
              thanks.
              

    If you want the current instance name, it is 'weblogic.Name' I think. If you
              want a list of all instances in the cluster, you can probably find it by browsing
              WebLogic MBeans.
              black <[email protected]> wrote:
              > Hi, there, how can I get each weblogic instance name in cluster env. in my code?
              > thanks.
              Dimitri
              

Maybe you are looking for

  • How to backup one Time Capsule with another Time Capsule?

    I have two Time Capsules and a Mac Mini. The first Time Capsule (TC1) is plugged by ethernet cable directly to my Mac Mini. It is also set up to provide my home with a wireless network. The second Time Capsule (TC2) is upstairs and connected to this

  • Can we have two iTune accounts on one computer

    Hi everyone, Just wanted to know if I can create two iTune accounts on one computer. My teen and I right now share one account and the problem gets confusing when we both want to use Itune gift cards (it's hard to keep track separately). I have a 2nd

  • Multi-mapping activate changes error

    Good afternoon! I want to use multi-mapping to split one IDoc(WBBDLD04) to some xml documents.I want XI to create one xml document per segment E1WBB01 of WBBDLD04 IDoc. I set Occurrence = 0..unbounded for target interface in interface mapping . Then

  • High availibility on 2500

    Hello guys, I have an environment with 1 AIR-CT2504-K9 implemented. I'm trying to configure N+1 High Availability with AIR-CT2504-HA-K9 following this article: http://www.cisco.com/c/en/us/td/docs/wireless/technology/hi_avail/N1_High_Availability_Dep

  • Nikon d700 tethered with lightroom3

    I am interested in shooting with my D700 and lightroom 3 tethered.  Is it possible for the image to be recored both on the card and on the tethered computer?