Execute powershell commands on a VM from the host.

I’m wondering if it’s possible to execute PowerShell commands from the host that will be execute on a virtual machine.
I have around 10 VM and I need to run the same command on all of it and I need to do the same in other 15 host.  
None of the VM belong to the same domain.

Yes, it's possible. 
It's not recommended to do any administrative tasks from the host. You should remove the GUI and all roles from the host except things related to Hyper-V and used in your environment like Failover Clustering and MPIO. 
As a best practice, set a Windows 8.1 VM as your management station and install RSAT tools on it including Hyper-V Manager. It also comes with Powershell modules you need to run Powershell commands and scripts against all your hosts and VMs.
On the machines to be managed by Powershell you need to enable Powershell Remoting. In Server 2012 and above and Windows 8 and above this is enabled out of the box (even core versions). In older versions of Windows
enable Powershell Remoting manually as shown in this post.
On the management Win 8.1 VM that has RSAT installed, if the managed machines belong to the same domain as the managing station, you're good to go. If not, run this command on the managing station:
winrm s winrm/config/client "@{TrustedHosts=""My2003Server,host2,host3,vm4""}"
Execute your scripts against multiple machines by using Invoke-Command as in:
'Computer1','Computer2','Computer3' | % {
$Result = Invoke-Command -Computer $_ -ScriptBlock {
Get-Process
$Result
This example, will execute the commands in the scriptblock on each of the 3 computers in line1, and return the result.
For more information see
Don Jones' Secrets of Powershell Remoting eBook.
Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable) _________________________________________________________________________________
Powershell: Learn it before it's an emergency http://technet.microsoft.com/en-us/scriptcenter/powershell.aspx http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

Similar Messages

  • Oracle E-Business Suite access from the Host machine

    Hellow,
    Please, after installing E-Business Suite and going through Post-configuration details, I would like to get access of my applications portal from the host system.
    I have tried several ways of doing that and would not know the steps to follow in order to access the portal directly from the physical host machine.
    I took the normal steps as when configuring end users and can ping the virtual machine from the Host system but can't do the same form the virtual machine of the host machine.
    I can ping another server and other machines int he same network but not the one on which the virtual machine is installed.
    Regards,
    N.M
    Edited by: user650358 on 17-Feb-2010 07:21

    Hi,
    I am confused first clear what is hostmachine and what is virtual machine.....
    call the machine which will access the application on virtual machine as CLIENT
    call the machine which is hosting the virtual machine a VIRTUAL MACHINE HOST
    call virtual machine as VIRTUAL MACHINE
    You mean I should change my host IP? It has so many applications using that localhost name.Is ther any setting done in the network and have you ever accessed an application installed on Virtual machine from the host machine?>
    changing of ip doesnt have any impact if ur applications are using hostname..if they are using ip then there is a issue,Yes i have acces EBIZ installed on virtula machine many times.
    And if ur working in a organization then ask ur network admins to check whats the issue..may be some were firewall issue also ..thats why i asked u to chnage ip.
    Regards

  • I cannot print envelopes from my laptop.  I can only print envelopes from the host computre on the network.  Why?  What do I need to do?

    I cannot print evnelopes from my laptop on Pages.  I can only print envelopes from the host computer on the network.  What do I need to do to be able to print envelopes from the laptop?

    Not sure what you are saying, what printer? what laptop? what network? what have you tried? but it sounds like you do not have the printer driver for the printer you use, on your laptop.
    Find the make and model and go to their website and look for the Mac Printer software and install it.
    Perhaps you do have it installed but haven't found it. Look down the list next to Printer: in the print dialog.
    I assume you have found the envelope templates in Pages' Template Chooser?
    Peter

  • How to execute unix command through odi and store the result in table

    I have to reconcile  if data is loaded in table from csv file or not . I have to create a oracle data integrator package/interface/procedure to execute unix command to count number of rows in the csv files and store the count result in a table then i have to query the loaded table and count number of rows there and store in the table and have to compare is counts are same or not,  Please assist me how to make package/interface/procedure to  execute unix command and store result in oracle table.
    Thanks in Advance

    Use ODI OS command tool in the ODI package.
    create an interface in ODI using LKM File to Sql and the output file generated with the csv file's row count as a source and the db table(where the count needs to be stored) as a target

  • Linux Server to connect Windows 2008 R2 Server to execute powershell commands

    Is it possible to do remotely executing powershell scripts on Windows 2008 R2 from Linux Server. I explored the option of FreeSSHD, but there is no option for password less authentication.
    Any thoughts and hints greatly appreciated.
    Retheesh
    Thanks and Regards, Retheesh Kumar R

    I am going to respectfully disagree with my post mates! Muhahahaha!
    If the target server (your Windows 2008 R2 box) can accept secure shell (ssh) connections, you should be able to ssh into the server then start PowerShell just like any other shell. That said, I suspect you will run into quirks. For example, I bet the
    "out-gridview" commandlet does some whacky stuff. You may get some strange terminal emulation junk too, but by and large you should be okay. I have Cygwin deployed to a Windows machine. That installation includes the OpenSSH package.
    [1] Cygwin http://www.cygwin.com/
    [2] How to run the OpenSSH SSHD server on Windows using Cygwin;
    http://www.noah.org/ssh/cygwin-sshd.html
    This would be like ssh'ing into some Linux machine then firing up ksh. If you're used to Linux, you no doubt know what I'm talking about.
    Now, here is the trick. You'll have to setup key based authentication on the Windows machine once you have your SSH server all setup. If you know how to do this on Linux, its the same process for Cygwin. The following article can help you -- remember the
    process is pretty much the same for Cygwin on Windows as it is for Linux distributions:
    [3] SSH with authentication key instead of password;
    http://www.debian-administration.org/articles/530
    You have your work cut out for you. Give it a try, and tell us how you fare.
    I hope this helps bro!
    Cheers,
    A-

  • Execute powershell command (new-object -comObject ...) in management pack

    Hello everyone
    I have a COM Object that want to use it in my management pack. When I write the powershell command "new-object -comObject ... " to create it outside of MP and in a ps1 file it works without any error. However when I write it in my MP, this
    error is showed in event viewer: "Retrieving the COM class factory for component with CLSID {clsID} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))."
    I have to mention that when I use vb script in my MP and using "CreateObject()", I don't have any problem.
    How can I use "new-object -comObject ... " in my management pack?
    thank you all
    Alireza

    Hi Marthijn,
    Actually I don't have any problem with powershell in my management packs. For example I can use "MOM.ScriptAPI"
    to create $oBag and return it to next module. My problem is only with that custom COM object. Interesting thing is that, it
    works fine when I create it in powershell file outside of MP, but when I create it in my MP, that error occures.
    thank you so much
    Alireza

  • Starting a WSAD server from the command prompt and not from the IDE UI

    Hi,
    is there a way to run the WSAD server from the command prompt instead of using the IDE UI . i have tried starting the server from the Directory i have installed WSAD " D:\Program Files\IBM\WebsphereStudio\runtimes\base_v5\bin>startServer.bat" but it gives the Following error " The system cannot find the path specified." i am working . do i have to specify the workspace that i am currently working on

    to see if the network adapter has registered with OPMN run: opmnctl status
    the 6200 message is a timeout which can be set in opmn.xml, the reports server(s) and other processes managed by OPMN should still stop.
    Try opmnctl stopall or opmnctl shutdown
    Does the timeout shows up regularly ie can you repeat it?
    After the stopall or shutdown try to start everything up again and try to stop the single reports server process again.

  • What command can be run from the cmd to inquire about the language layout that is used right now?

    I have windows 7 32bit platform. Is there any command that can be run from the command line just to inquire about the language bar that is currently in use? Suppose I have English keyboard on my machine but I am switching between 3 languages when I write
    my documents (e.g. English, German, Spanish). I want to know if there is any way to tell what language layout that is in current use as seen in the language bar. This question is not about how to change language layout from the command line -- just to know
    what layout. For example, the command can return some sort of string to indicate which layout is currently in use: "english", "german", "spanish", and so on.
    My ultimate goal from this question is to pass this output into an external editor that will hopefully change font based on the input language? Any help to achieve this goal will be much appreciated.
    Or put differently, what is the best way to tell an external editor like Emacs about the current language layout that is in current use?

    For the current input language you can try using
    reg query "HKCU\Keyboard Layout\Preload" /v 1
    The return value includes an eight digit hex value. The first four digits indicate either default layout for the language (all zeros) or a variation (non-zero). The last four digits are the locale id - see:
    http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx
    From this table, you can see in the example above my input language is English - Australia. 
    For the keyboard layout you could try
    WMIC Path Win32_Keyboard Get Layout
    0409 is an English - US keyboard.
    For a few other ideas/methods try reading
    http://p0w3rsh3ll.wordpress.com/2013/06/07/about-keyboard-layouts/

  • Powershell command for adding permissions in the "winrm configsddl wmi" menu

    Hello,
    I was wondering if there was any powershell command that would be the equivalent of adding a user in the menu brought up by typing
    winrm configsddl wmi
    I want to be able to add Read permission for users.
    Thanks,
    Brian

    Hi Brian,
    You can try to create and add the user to the local group which has been set as the read permission of the "http://schemas.microsoft.com/wbem/wsman/1/wmi".
    To add local users to local group in powershell, please refer to this thread:
    Adding local user accounts to Local administrator group:
    http://powershell.com/cs/forums/t/6369.aspx
    I hope this helps.

  • Using Powershell to delete all users from the Portal

    Summary
    This script will delete all users from the Portal except for Administrator and the Built-In Sync account.
    Based on Markus's "Delete a User" script.
    Useful when developing your system if you want to quickly clear out the data and start again.
    set-variable -name URI -value "http://localhost:5725/resourcemanagementservice' " -option constant
    function DeleteObject
    PARAM($objectType, $objectId)
    END
    $importObject = New-Object Microsoft.ResourceManagement.Automation.ObjectModel.ImportObject
    $importObject.ObjectType = $objectType
    $importObject.TargetObjectIdentifier = $objectId
    $importObject.SourceObjectIdentifier = $objectId
    $importObject.State = 2
    $importObject | Import-FIMConfig -uri $URI
    if(@(get-pssnapin | where-object {$_.Name -eq "FIMAutomation"} ).count -eq 0) {add-pssnapin FIMAutomation}
    $allobjects = export-fimconfig -uri $URI `
    –onlyBaseResources `
    -customconfig "/Person"
    $allobjects | Foreach-Object {
    $displayName = $_.ResourceManagementObject.ResourceManagementAttributes | `
    Where-Object {$_.AttributeName -eq "DisplayName"}
    if([string]::Compare($displayName.Value, "Administrator", $True) -eq 0)
    {write-host "Administrator NOT deleted"}
    elseif([string]::Compare($displayName.Value, "Built-in Synchronization Account", $True) -eq 0)
    {write-host "Built-in Synchronization Account NOT deleted"}
    else {
    $objectId = (($_.ResourceManagementObject.ObjectIdentifier).split(":"))[2]
    DeleteObject -objectType "Person" `
    -objectId $objectId
    write-host "`nObject deleted`n" $displayName.Value }
    Go to the FIM ScriptBox
    http://www.wapshere.com/missmiis

    The DeleteObject function opens and closes a connection for each object.  This approach is faster:
    http://social.technet.microsoft.com/wiki/contents/articles/23570.how-to-use-powershell-to-delete-fim-users-that-have-a-null-attribute-name.aspx
    Mike Crowley | MVP
    My Blog --
    Planet Technologies

  • List all alerts from the host

    Hi All,
    How can I find all alerts that have been generated for all targets on the particular host based on the time frame? I looked at the repository db, but can't find table that can provide me this information. I need all alerts for month of March on the particular host. Can any agent commands provide this info?
    Thanks for your help.
    Greg

    Hi Krishnan,
    before I mark it answered....
    I was unable to pull the data I need based on the host name. this is my search criteria:
    =====================
    Shows open and closed
    Incidents and Problems
    Last updated between Mar 1, 2015 4:59:42 PM EST and Apr 1, 2015 4:58:56 PM EDT
    Target types: Agent, Application Deployment, Automatic Storage Management, Beacon, Cluster, Cluster ASM, Cluster Database, Database Instance, Database System, EM Service, Group, Host, Listener, Management Servers, Metadata Repository, OMS Console, OMS Platform, OMS and Repository, Oracle Fusion Middleware Farm, Oracle HTTP Server, Oracle High Availability Service, Oracle Home, Oracle Management Service, Oracle WebLogic Domain, Oracle WebLogic Server
    Target name contains HOST_NAME_HERE
    Target and all members
    Not showing diagnostic incidents

  • The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message - while executing powershell command for sharepoint online site

    " +The underlying connection was closed: An unexpected error occurred on a receive..Exception.Message " OR sometimes
    "The remote server returned an error: (503) Server Unavailable..Exception.Message"
    Getting exception above when performing various operation (site coll creating, group creation, adding users to group) for sharepoint online (Office 365) site using powershell script.
    I want to create 3500 site collections using PS script. In-between getting above exception so it will skip one site collection creating and working again. for eg. after creating 11 site coll, script will through above exception and so 12th site coll will
    not be create but working fine from 13 and so on...

    Remote server seems working to me...any additional check?
    if problem with remote server then may be loop to create site provisioning should not start again..Right?
    any idea?

  • SCCM 2012 sp1: howto remotely execute powershell commands?

    Hi,
    Please advise on howto run remote powershell scripts to an SCCM 2012 SP1-server.
    Locally importing the module (on sccm 2012) works fine, but not remotely. It tells I should run from x86 console, but I am!
    Please advise.
    J.
    Jan Hoedt

    Start the SCCM Console and start Powershell from there. (left-top "Connect via Windows Powershell")
    This will register the CM PSDrive for the user who started the console.
    The PSDrive will not be available to a PowerShell IDE or another editor. However in looking at this, it shows that it's loading "Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml". So I tried the following:
    Update-TypeData
    -PrependPath
    ($Env:SMS_ADMIN_UI_PATH.Substring(0,$Env:SMS_ADMIN_UI_PATH.Length-5)
    +
    '\Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml')
    That seems to load the correct datatype. However I still get an error doing the following command (example):
    New-PSDrive
    -Name
    "CAS"
    -PSProvider
    CMSite
    -Root
    "ServerUNC"
    Error:
    New-PSDrive : Object reference not set to an instance of an object.
    Hopefully someone knows more about TypeData...
    -Ken

  • Executing system command (third party program) from extend script without showing console on windows

    I am using following code on mac:
    app.system("/path/to/external/executable &");
    It runs external program in background (without showing console/terminal).
    On windows I tried many things like:
    app.system('start "" "/path/to/external/executable"');
    app.system('start "" /B "/path/to/external/executable"');
    And I was also trying to solve it using visual basic.
    Unfortunately everytime I use app.system(...) then windows console is showed on the screen for half of the second, then it disappears and progrm runs in background. Is it possible to avoid showing console window? Maybe there is another way of executing third party program?

    You can try to save a vbscript :
    Dim objShell
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    objShell.Run("""\path\to\external\executable"""), 0, True
    Set objShell = Nothing
    than just execute it from javascript: 
    var vbFile = new File("path to your vbscript file")
    vb.execute();

  • Can call a function from SQL COMMAND but can't from the SHUTTLE help please

    I've read this article
    ARTICLE
    I've written the code in a function called SURVEY_USERS that takes one variable
    when I run the following in the SQL builder:
    SELECT SURVEY_USERS('canns') from DUAL;I get
    SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM where smteam.division_manager=canns and rownum = 1
    UNION
    SELECT SMTEAM.dept_manager DS, smteam.dept_manager RV from SMTEAM LEFT where smteam.division_manager=canns
    UNION
    SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM where smteam.division_manager=cannswhich is what I want but when I put in into the "list of values definition".
    RETURN SCREPORTS.SURVEY_USERS('canns');I get
    Error     ORA-06550: line 1, column 188: PL/SQL: ORA-00904: "CANNS": invalid identifier ORA-00904: "CANNS": invalid identifier ORA-06550: line 1, column 7: PL/SQL: SQL Statement ignored ORA-00904: "CANNS": invalid identifierI'm just confused as to what I'm doing wrong. I'm passing the same thing to the function...and it appears to be working in the SQL workshop and not the actual LOV Shuttle.
    Edited by: bostonmacosx on Sep 12, 2012 3:45 PM

    Here is some of the function
    create or replace function "SURVEY_USERS"
    (app_user in VARCHAR2)
    return VARCHAR2
    is
      vp_exists INTEGER;
      ed_exists INTEGER;
      dr_exists INTEGER;
      mngr_exists INTEGER;
    begin
    SELECT COUNT(*) into vp_exists
      FROM smteam
      WHERE area_manager= app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO ed_exists
      FROM smteam
      WHERE division_manager = app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO dr_exists
      FROM smteam
      WHERE dept_manager = app_user
      AND ROWNUM = 1;
      SELECT COUNT(*) INTO mngr_exists
      FROM smteam
      WHERE wdmanagername = app_user
      AND ROWNUM = 1;
    --dbms_output.put_line (vp_exists);
    --dbms_output.put_line (ed_exists);
    --dbms_output.put_line (dr_exists);
    --dbms_output.put_line (mngr_exists);
    IF (vp_exists = 1) THEN
      RETURN 'SELECT smteam.area_manager DS,smteam.area_manager RV from SMTEAM where smteam.area_manager='''||app_user||''' and ROWNUM = 1
       UNION
       SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM where smteam.area_manager='''||app_user||'''
       UNION
         SELECT smteam.dept_manager DS, smteam.dept_manager RV from SMTEAM  where smteam.area_manager='''||app_user||'''
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.area_manager='''||app_user||'''';
    END IF;
    IF (ed_exists = 1 and vp_exists=0) THEN
        RETURN 'SELECT smteam.division_manager DS, smteam.division_manager RV from SMTEAM  where smteam.division_manager='''||app_user||''' and rownum = 1
       UNION
         SELECT SMTEAM.dept_manager DS, smteam.dept_manager RV from SMTEAM LEFT where smteam.division_manager='''||app_user||'''
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM where smteam.division_manager='''||app_user||'''';
      END IF;
    IF (dr_exists = 1 and ed_exists=0 and vp_exists=0) THEN
         RETURN 'SELECT smteam.dept_manager DS, smteam.dept_manager RV from SMTEAM  where smteam.dept_manager=:'''||app_user||'''and rownum = 1
       UNION
        SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.dept_manager='''||app_user||'''';
      END IF;
    IF (mngr_exists = 1 and ed_exists=0 and vp_exists=0 and dr_exists=0) THEN
        RETURN  'SELECT smteam.wdmanagername DS, smteam.wdmanagername RV from SMTEAM  where smteam.wdmanagername=:'''||app_user||''' and rownum = 1';
      END IF;
    END;
    Edited by: bostonmacosx on Sep 12, 2012 3:56 PM

Maybe you are looking for