Similar to connecting to remote computer using WSManagement, how to do it through powershell terminal?

I have the following code to connect to the remote powershell and execute script on remote machine :WSManConnectionInfo connectionInfo = new WSManConnectionInfo(false, "MachineName", 5985, "/wsman", shellUri, credential);
using (Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo))
runspace.Open();
using (PowerShell powershell = PowerShell.Create())
powershell.Runspace = runspace;
String file = @"C:\scripts\createUser.ps1";
powershell.Commands.AddScript(System.IO.File.ReadAllText(file));
Collection<PSObject> results = powershell.Invoke();
}How to execute the script in same way from powershell command prompt?

Hi,
The Invoke-Command cmdlet should to the trick for you using WinRM.
Invoke-Command -ComputerName MachineName -Scriptblock {c:\scripts\createuser.ps1}
The parameter -File could also be used for pointing to an UNC share or so.
More information regarding the cmdlet is found below..
http://technet.microsoft.com/en-us/library/hh849719.aspx
Microsoft Certified Trainer
MCSE: Desktop, Server, Private Cloud, Messaging
Blog: http://365lab.net

Similar Messages

  • How to connect to remote computer using ARD and AE

    Does anyone have detailed instructions on how I can us my AirPort Extreme and setup all the ports to allow the use of ARD remotely?

    You can configure your AirPort Extreme for ARD using the AirPort Utility. ARD is one of the choices under Port Mapping.
    You get to the port mapping option, as follows:
    Run the AirPort Utility.
    Select the AirPort Extreme, and then, select Edit.
    Select the Network tab to enable it.
    Click on the "+" button under the Port Settings field.
    Click on the drop-down arrow to the right of the Description field. (see image below)
    Select Apple Remote Desktop. This will automatically populate the other fields on the page.
    Select Save, and then, select Update.
    Allow the base station to reset.

  • Using different credetial to connect to remote computer to get Cert information

    I am using following function to get cert details from remote computers. How do I change it to accept credentials to connect to remote computer?
    PS : Remote computers are windows 2003 computers without PowerShell installed on it.
    function Get-Cert( $computer=$env:computername ){    $ro=[System.Security.Cryptography.X509Certificates.OpenFlags]"ReadOnly"    $lm=[System.Security.Cryptography.X509Certificates.StoreLocation]"LocalMachine"    $store=new-object System.Security.Cryptography.X509Certificates.X509Store("\\$computer\my",$lm)    $store.Open($ro)    $store.Certificates}Get-Cert ServerA
    -Edatha-

    Certainly.  Here's a quick example that uses the PowerShell registry provider as a quick an easy way to enumerate the subkeys of HKLM\Software\Microsoft\SystemCertificates\MY\Certificates\ , and to read the Blob value as a byte array.  In your
    case, you'd probably want to look into using something like WMI's StdRegProv class to accomplish the same thing.
    Once you have the byte array, just pass it to the constructor of X509Certificate2.  (Note the unary comma in that constructor call; we're binding an object to the -ArgumentList parameter of New-Object, and when you're calling constructors that take
    a single array argument, you need the comma.)
    Get-ChildItem HKLM:\SOFTWARE\Microsoft\SystemCertificates\MY\Certificates |
    ForEach-Object {
    $byteArray = (Get-ItemProperty -Path $_.PSPath -Name Blob).Blob
    $certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2(,$byteArray)
    $certificate

  • How to open multi-windows to operate a remote compute using socket

    hi, please help me.
    I want to develop a program, it can open multi-windows to operate the remote comput at one time just like NetTerm. It use socket to setup connection with remote computer.
    Now I am using a Thread class to setup socket connection with computer, and use Thread's static varible to control all kinds of action of socket.But it can work only when openning one window,because all the thread instances share the same static variable.
    How to do it? Not using Thread? Then the frame will be frozen.
    All adivse are welcomed.Thank you.

    Maybe I don't say it clearly.The program need to show the output of the socket in the JTextArea and transfer the user input to the input of the socket to control the remote computer.

  • JDBC connect from remote computer fails

    Hi all,
    I have successfully installed the XE server and I can connect over JDBC from clients running locally on the machine where the XE server is installed.
    However when I try to connect from a remote computer using the same client I get an error saying: The Network Adapter could not establish the connection
    I can ping the machine with XE installed and all firewalls on the machines are turned off.
    Any ideas on the subject of JDBC remote connect to XE server? Or is it simply that it is not supported?
    Appreciate all the help I can get.
    Thanks,
    /Anders

    On my machine I have the listener bound to local interface.
    Listener.ora has hostname in it, and this is the listener status:
    As status shows the hostname is resolved to localhost, on this machine I am unable (with this configuration) to share the db to other machines (I do not have oracle client on my other pc, but telnet is unable to connect to port 1521).
    Changing hostname to ipaddres solves.
    [andrea@bones ~]$ lsnrctl status
    LSNRCTL for Linux: Version 10.2.0.1.0 - Beta on 15-DEC-2005 21:28:51
    Copyright (c) 1991, 2005, Oracle.  All rights reserved.
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bones)(PORT=1521)))
    STATUS of the LISTENER
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Beta
    Start Date                15-DEC-2005 21:28:40
    Uptime                    0 days 0 hr. 0 min. 11 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Default Service           XE
    Listener Parameter File   /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora
    Listener Log File         /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/log/listener.log
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=8080))(Presentation=HTTP)(Session=RAW))
    Services Summary...
    Service "PLSExtProc" has 1 instance(s).
      Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
    Service "XE" has 1 instance(s).
      Instance "XE", status READY, has 1 handler(s) for this service...
    Service "XEXDB" has 1 instance(s).
      Instance "XE", status READY, has 1 handler(s) for this service...
    Service "XE_XPT" has 1 instance(s).
      Instance "XE", status READY, has 1 handler(s) for this service...
    The command completed successfully
    [andrea@bones ~]$

  • My 5th gen Ipod won't do anything but show the " Connect to your computer, use itunes to restore" screen. However my computer nor anyone else's will recognize my ipod. What can I do?

    My ipod will not do anything but show a screen that asks to "connect ipod to computer, use itunes to restore" My computer however will not recognize my ipod at all so there is no way to restore my ipod. I am not skilled in computers but if anyone has a step by step that would be great.

    Did you try a hard reset with the iPod still connected to your PC?  Have you tried multiple USB ports, preferably high powered USB 2.0 ports?
    To do a hard reset, first make sure the hold switch is in the Off position, then press and hold both the Select (Center) and Menu buttons together long enough for the Apple logo to appear.
    Have you also worked through each and every single troubleshooting suggestion in this Apple support document?
    iPod not recognized in 'My Computer' and in iTunes for Windows
    B-rock

  • My ipod says "connect to your computer. use itunes to restore."

    My ipod says "connect to your computer. use itunes to restore."
    So I plug it into the computer and itunes says it needs to restore, so I click restore, everything seems to go fine, and it says the ipod needs to restart, it does, has a lil progress bar go across the ipod screen, then itunes detects the ipod again and says it needs to be restored again. This is an endless loop, anyone have any idea how to solve this problem?

    Have you had a chance to look at this troubleshooting page? Have a look at the bottom section that covers what to try if restoring doesn't work, it may be of some help: iTunes has detected an iPod in recovery mode - Use iTunes to restore

  • I can not get my Ipod to connect with my computer using a usb cord

    I can not get my Ipod to connect with my computer using my usb cord ?

    Hi starhalcomb,
    I'm sorry to hear you are having issues with your iPod touch. I also apologize, I'm a bit unclear on your exact configuration. If you are having issues with your iPod touch not being recognized in iTunes when you connect via USB, you may find the information and troubleshooting steps outlined in one of the following articles helpful:
    iPhone, iPad, or iPod not recognized in iTunes for Windows - Apple Support
    If you don't see your connected device in iTunes for Mac - Apple Support
    Regards,
    - Brenden

  • Airport Extreme Route - Logging into remote computer using VPN

    is there anything i need to change on my airport extreme router. I used to be able to access remote computer via vpn and now I cant ever since i started using the airport extreme. Im trying to access remote computer using windows xp home.

    bkohlmeier wrote:
    On one of the 2wire config screens last night, it showed my various devices and next to each one said "IP" of 108.54.... so it was showing the public IP of each one, versus say "192.168.1.160".
    Ok, that is weird. Is each IP different and how many devices do you have getting public IP's.. there should only be one available and the only device getting it should be the extreme.
    If you only need a bridged modem. go out and buy a cheap single port modem. (I presume this is DSL service. Sorry I am not in US, so what is obvious to you may need spelling out).
    We often use the cheapest TP-Link modem here.. TD-8817 which are like $25 for bridged modem.. works really well.
    I think also you will find as far as pc is concerned the 2wire is actually the better router. Apple decided to use NAT-PMP on their routers instead of near universal upnp used by all windows networking and just about everything else. That makes opening ports that much harder on the Extreme for games etc.
    With the new version utility you can turn on guest network even with the Extreme in bridge.. and what you miss in terms of dhcp is not that great.
    If you want to get it working, let me suggest bridging the extreme for the moment. I am sure you will find no issues with Remote Desktop direct through the 2wire, as you probably used it in the past that way.

  • It says...connect to your computer, use itunes to restore..but it wont work

    1st off: i own an ipod video. Ok, so when I turn on my ipod, this white screen comes up and it says connect to your computer, use itunes to restore. And then when I restore my ipod on itunes...it just keeps making me restore it over and over again. I dont no wat to do and I'm getting really frustrated. i need someone to tell me wat to do cause I just do the same thing over and over again, and it doesnt work. Please help me!!!

    Have you had a chance to look at this troubleshooting page? Have a look at the bottom section that covers what to try if restoring doesn't work, it may be of some help: iTunes has detected an iPod in recovery mode - Use iTunes to restore

  • "Connect to your computer, use iTunes to restore" loop! Please help!!

    Everytime I try to turn on my iPod, it gives me the "Connect to your computer, use iTunes to restore" message so I use iTunes to restore but once it's "done" restoring, it tells me the iPod is still in Recovery Mode and needs to be restored. Someone told me to change the file to a Fat32 file but it's already a Fat32. Someone else suggested to change the drive letter but , unless I'm not doing it right, that's not working either. Any other suggestions?? Thanks!

    Yes, it does need to recognize the iPod in order for you to do something like this.
    Have you first tried working through these troubleshooting steps to get your iPod recognized in iTunes?
    The Five R's
    -Kylene

  • My iPhone 5 is freezing when connected to the charger. This is not happinning if it is connected to the computer USB. How to solve this problem?

    My iPhone 5 is freezing when connected to the charger. This is not happinning if it is connected to the computer USB. How to solve this problem?

    Possibly faulty charger. The supplied Apple Charger is covered by the iPhone Warranty. Make Genius reservation or set up service and take or send iPhone and Charger to Apple for resolution.

  • I have to change a computer using Indesign How to transfer the license

    I have to change a computer using Indesign
    How to transfer the license

    De-activate on the first computer, then install on the new one and activate. Nothing special is required as long as the user does not change.

  • HT3819 I can use remote on my iPhone to connect with my iTunes library, but i can't connect to another computer using home sharing to access apple tv.  I have used the same access ID and password that is used for the apple tv.

    I can use the Remote app on my iphone to connect with my itunes library on my computer, but I can't connect to the Apple TV using home sharing with another computer in the house.  I am using the same ID and password that the apple tv uses to connect with the other computer.  Also how do I check what version of IOS that my iphone is using?

    Version:
    iOS Settings>General About (or it'll say when you hook it up to iTunes)
    Are all the devices on the same physical network?  I think you're saying all are set up using the same home sharing credentials.
    If you've not done so restart all devices and your router.
    If you can get any of the devices connected by ethernet to reduce the wifi burden that may help but to be honest I would not expect simply beoing on wifi to prevent devices/computers appearing in the list.
    Does the other computer have any firewall or port blocking software running?

  • Cannot connect to remote computer

    Hi all, I've spent a lot of time trying to figure this out, would appreciate any help as I'm new to ARD, (3.3.2 version).
    Here goes... I have 5 Macs on my home network, and have had very little problem connecting and controlling them from ARD. My problems start when I try to connect to my not-to-computer-savvy relatives elsewhere.
    The first one is running a new iMac behind an airport extreme, I have ticked thier Remote Management box and opened the ARD ports on the extreme and I think I have correctly set up a static IP address of 10.0.1.3, on the 'configure IPv4' 'using DHCP with manual address'. I have then asked that user to give me his IP address from 'http://www.myipaddress.com' and this is the address I type into ARD - Scanner - Network Address. However this will not work, I cannot 'see' them or let me verify the user when I try to 'control' of 'observe'.
    The second computer is behind a 'Linksys WAG 54G2', so I'll need to forward the ports like this.. http://portforward.com/english/routers/portforwarding/Linksys/WAG54G2/Apple_RemoteDesktop.htm
    I have also tried to 'Ping' without success both these computers using 'Network Utility'
    Very frustrated. Any help appreciated.
    Max

    Do you mean, you can access the target computer using the other computer and not the
    one you’re on right now? Can you ping the target computer using that computer
    and vice versa? Just make sure that the computers are pinging each other to
    ensure that they are communicating.

Maybe you are looking for