Habeeb's profileHABEEB ALI SHAIK PhotosBlogListsMore Tools Help

Blog


    How to Shutdown a remote computer using Powershell Script

     

    I’ve written a Powershell script that shutdowns a remote computer. This Powershell script use WMI to shutdown the remote system.

    1. Open notepad

    2. Copy and paste below text to notepad

    3. Save the file with .ps1 extension.

    # ---------- SCRIPT STARTS HERE--------------

    #remote shutdown script
    #usage remoteshutdown.ps1 computername

    $objsystem = get-wmiobject -computername $args[0] -query "select * from win32_operatingsystem"
    $result = $objsystem.shutdown()
    if ($result.returnvalue -match "0") {
    write-host "$args[0] - shutdown command completed" -foregroundcolor green
    }
    else {
    write-host "$args[0] - unable to send shutdown command" -foregroundcolor red
    }

    # ---------- SCRIPT ENDSS HERE--------------

    Comments

    Please wait...
    Sorry, the comment you entered is too long. Please shorten it.
    You didn't enter anything. Please try again.
    Sorry, we can't add your comment right now. Please try again later.
    To add a comment, you need permission from your parent. Ask for permission
    Your parent has turned off comments.
    Sorry, we can't delete your comment right now. Please try again later.
    You've exceeded the maximum number of comments that can be left in one day. Please try again in 24 hours.
    Your account has had the ability to leave comments disabled because our systems indicate that you may be spamming other users. If you believe that your account has been disabled in error please contact Windows Live support.
    Complete the security check below to finish leaving your comment.
    The characters you type in the security check must match the characters in the picture or audio.

    To add a comment, sign in with your Windows Live ID (if you use Hotmail, Messenger, or Xbox LIVE, you have a Windows Live ID). Sign in


    Don't have a Windows Live ID? Sign up

    Trackbacks

    The trackback URL for this entry is:
    http://habeebshaikali.spaces.live.com/blog/cns!AC13A3C850A713DF!429.trak
    Weblogs that reference this entry
    • None