How to get the current user name of the host who is occupying a specific VM?

I'm developing a winform app with c# code to manage Hyper-V. I need to remind someone if he/she would take a VM which has already been occupied by others.
Is there any powershell cmd or WMI interface to get the current user of a specific VM?
Thanks!

Hiya,
from cmd there are quser(Query user) and qwinsta(Query Session)
which should give you that. Don't know how you can incoorperate that in C#, but that should give you something to work with :)
https://technet.microsoft.com/en-us/library/cc785434.aspx
https://technet.microsoft.com/en-us/library/cc788125.aspx

Similar Messages

  • How to get the current user name in Provider hosted app using appOnlyAccessToken

    Hi, 
    Please help me, how to get the HostWeb UserName in Provider Hosted App
    i have Provider hosted App, and Anonymous Authentication is enabled on AppWeb, using appOnlyAccessToken
    Below code does not return current user who Log in in hostweb, it is returning
    SharePoint App (app@sharepoint)
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;
    Below code gives a blank name when Anonymous Authentication is enabled, if Anonymous Authentication is disabled
    app prompts for credentials 
    HttpContext.Current.User.Identity.Name
    Thanks
    Ram

    Hi,
    Since you are using a provider Hosted app if you want to get the current logged in name than do not use AppOnlyAccessToken else use AccessToken which is App + user Context AccessToken.
    then 
    Web web = clientContext.Web;
    clientContext.Load(web);
    clientContext.ExecuteQuery();
    clientContext.Load(web.CurrentUser);
    clientContext.ExecuteQuery();
    clientContext.Web.CurrentUser.LoginName;will return proper user Name.
    HttpContext.Current.User.Identity.Name will never return the user as this object is related to IIS server of your App Server not sharepoint.you should set this as Anonymous in case of provider hosted app.you can download the below sample which uses the AccessToken which has user name in it.https://code.msdn.microsoft.com/Working-provider-hosted-8fdf2d95
    Whenever you see a reply and if you think is helpful,Vote As Helpful! And whenever you see a reply being an answer to the question of the thread, click Mark As Answer

  • When I try to log into the app store to update apps or buy apps the user name that appears is an old one and it will not bring up the current user name/ email how do I stop that so that my current email show up ??

    When I try to log into the app store to update apps or buy apps the user name that appears is an old one and it will not bring up the current user name/ email how do I stop that so that my current email show up ??

    Settings>Store: Tap the AppleID and choose "Sign Out", it will then prompt you to sign in and you can use the new AppleID.
    NOTE: Apps must be updated with the AppleID they were purchased under.
    EE

  • How to find the current User Name and stored in which table

    In which table the current user name (Login) is stored?

    Hi Mohanapriya
    The query provided by Gordon can not run on query generator as the $USER is a runtime variable.
    You need to save it to a query then use it in a FMS(Formatted Search.)
    Just open a form(ex:sales order ), click the field in which you want to show the user name,
    then press ****+F2 or Tools->Search Function->Define,
    Search by Saved query,then assign the save query to the field.
    After that ,you can run the FMS(shift+F2) to get the current user info.
    Regards,
    Syn Qin
    SAP Business One Forums Team

  • HT204053 Can I have two Iphones connected to one icloud account and if so, how do I change the icloud user name on the phone

    Can I have two Iphones connected to one icloud account and if so, how do I change the icloud user name on the phone

    Welcome to the Apple Community.
    Yes you can use one iCloud account between multiple devices.
    What do you mean 'change the iCloud user name'.

  • How to get customer number and name from the SD document

    Hi All,
    Can you please let me know how to get Customer Number and Name from the SD Document?
    Thanks a lot....
    Anil

    Hi,
    It will be displayed in the SD (BIlling document) itself,  you clikc on the VF03. The customer name and number will also appear in the SO document also Tcode VA03
    regards,
    radhika
    Edited by: kolipara radhika on Jul 10, 2009 5:32 AM

  • Using the login user name in the report

    It will be appreciated if someone can help on the following:
    How can I use the login user name in the report?
    I mean that the report will be build on SQL statement look like :
    Select a, b, c, d
    For table
    Where a = <the user name used to login to htmldb>
    Thanks

    select a,b,c,d
    from table
    where a= :APP_USER

  • How Do I Display the Current User Name on SharePoint

    I have a customer using a hosted SharePoint 2013 multi-tenant solution and they have asked to have the end user's name to be displayed when logged in. It seems like I have seen this done on other SharePoint deployments but I can't seem to figure out how
    or where to enable this now.
    Can anyone tell me how to display the current user's name in SharePoint 2013?

    Hi
    check this solution
    http://www.c-sharpcorner.com/UploadFile/sagarp/how-to-get-the-current-logged-in-user-and-display-name-using/
    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

  • How to Get Most Current User View Before Checking In.

    Hi,
    We have several custom workflows which users can start from end-user menu and have some resource accounts created/modified after approvals.
    User view is checked out once at the beginning of each workflow, then some user attributes are modified through forms and user view is checked in with new attributes at the end.
    If any user starts a workflow (say W2) before completion of another workflow (say W1) he started before, and W1 is completed when W2 is waiting for approvals or etc., W2 completely discards changes made to user view through W1 since it has already checked out the user view before.
    If I checkout the user once more just before checkin, I'm able to get a current user view but this time changes made through forms used in the current workflow are lost.
    What's the best way, to get an updated user view of the user without overwriting any changes made out of the running workflow and losing form data?
    Regards,
    Mehtap.

    In a situation like this, you should probably change the front end to store the changes in workflow variables instead of using the view directly. Then, post approval, you checkout the view and apply the changes. I've used this approach to perform changes on large numbers of users (kind of like a bulk action, only more reliable).
    Alternatively, you can checkout the user object at the beginning of the workflow, and this will prevent your race condition by putting a lock on it. This will obviously cause problems (for you) if your users expect to be able to do multiple changes simultaneously. Don't try this approach if an angry mob will storm your cubicle -- IDM coders are hard to come by.
    Jason

  • How to get logged in user name from windows service c#

    i use the below code to get logged in user name.
    private string GetLoggedInUser()
    string userName = "";
    if (System.Security.Principal.WindowsIdentity.GetCurrent() != null)
    userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;
    return userName;
    just do not understand why it is not giving a logged in user name rather it is return data in this format
    NT AUTHORITY\SYSTEM but i want to get user name.
    i try to run my service as Local Service and local system account but in every case i am getting this string
    NT AUTHORITY\SYSTEM instead of logged in user name.
    so please guide me what to change in code. thanks

    System is the account the service is running under.
    There can be none or many interactive users be logged in. What if none or multiple are logged in? Which one are you referring to then?
    Armin

  • How to have SAP pull the current user as of the document owner

    Dear All,
    We are using SAP88 PL21 US localization. When they create marketing document, they want to default the doc owner to the current user. Is there anyway we can setup in SAP? If we have to create UDV, where can I pull the current user code? Thanks.
    Regards,
    Yuyka

    Hi Yuka.......
    This is Possible by using Data Ownership Authorization........
    Please check this also......
    http://forums.sdn.sap.com/thread.jspa?threadID=1033556
    Regards,
    Rahul

  • To connect the Current User Filter with the Excel Web Access

    Hello,
    I have uploaded an excel sheet which has data in Pivot table format into SharePoint site and then by using the current user filter I am trying to connect the filter (sharepoint profile user property) to a parameter in the excel sheet. I have defined one
    of the pivot filter as the parameter. But all this, raises an error as below 
    "Unable to set one or more parameters. An error occurred while attempting to set one or more parameters in this workbook. As a result, none of the parameters has been set. Click OK to return to the workbook."
    please assist.
    Thanks & Regards
    Thank You

    I had referred this link but the example provided is related linking dashboard filters with the pivot table filter and i require to connect a current user filter.
    The current user filter does not have any properties similar to what the dashboard filter have and we are not looking at using dashboard for our requirement.
    Thank You
    Thank You

  • How to get the current use name edited the page

    Hi All,
    I have a table which contains set of users,
    namely
    A
    B
    C
    When the user A changes a particular pages and in that page i have a page item named LAST REVIEWED BY its Display only column and i need to Auto Populated the user Name A
    How to do this ?
    Thanks & Regards
    Srikkanth.M

    Put a Trigger on your Table which fills the column using
        NEW.LAST_REVIEWED_BY := v('APP_USER');
        ...brgds,
    Peter
    Blog: http://www.oracle-and-apex.com
    ApexLib: http://apexlib.oracleapex.info
    BuilderPlugin: http://builderplugin.oracleapex.info
    Work: http://www.click-click.at

  • How to get colla..room name in the notification mail  while creating a task

    Hi All,
             I create a collaboration room, there i created one task. Asusal all the task assignees are getting notification mail. but in the mail content there is no mention of particular collaboration room. from where we created that particular task, this is creating some confusion to the users who are getting this notification mail,
    if any one knows please let us know.
    Regards,
    Navaneethan

    >
    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 ).

  • How to get rid of user tip on the screen of windows 8

    hi
    I do not want the display of "switch between apps" user tip that keeps on populating everytime.
    How can i get rid of it,please suggest. Thanks In advance.
    My PC configuration 
    Link to image 1
    Link to image 2
    Moderator note: large image(s) converted to link(s):  About Posting Pictures In The Forums

    hi saichandra38,
    Welcome to the Forums.
    Can you try to follow the guide below on how to disable App Switching and observe.
    How to Turn App Switching On or Off in Windows 8 and Windows 8.1
    Let me know how it goes.
    Regards
    Did someone help you today? Press the star on the left to thank them with a Kudo!
    If you find a post helpful and it answers your question, please mark it as an "Accepted Solution"! This will help the rest of the Community with similar issues identify the verified solution and benefit from it.
    Follow @LenovoForums on Twitter!

Maybe you are looking for

  • How do I install windows home server on my power mac?

    My power mac g4 is the graphite version I think and I put the disc in my computer and booted up and I pressed alt on my windows keyboard ( i think its options on a mac keyboard) but when I got to the screen where it displays the options to boot from

  • Not sure if I can install this edition on my computer (Adobe lightroom 3)

    So today I went to my local bestbuy and asked for Adobe lightroom 3, they gave it to me and I went home. When I got home I saw that its the Student and Teacher edition. I am not a student or teacher at any university, I am  in High School, I was wond

  • High REDO Generation for enqueue and dequeue

    Hi, We have found high redo generation while enqueue and dequeue. Which is in-turn affecting our database performance. Please find a sample test result below : Create the Type:- CREATE OR REPLACE type src_message_type_new_1 as object( no varchar(10),

  • Unsure I have the correct version Flash Player

    My version of Flash Player, according to the version test on adobe.com is WIN 10,0,45,2 at first glance this seems to be in order. but upon closer inspection I realized that the separating factors are commas, not periods. Therefore, I should have 10.

  • Moving a Node in a Tree with Xerces

    Hi, I have a XML Doc like this: <personnel>      <person>           <name>                 <family>                 </family>           </name>      </person> </personnel>now I want to move the "family" Node upper so I get this: <personnel>      <per