Windows Powershell Execute external commands _powershell

Source: Internet
Author: User
Tags microsoft sql server reserved

Powershell can perform external commands as well as CMD.

View network port status through Netstat

PS c:\ps> netstat

Active connections

 Proto Local address     Foreign address    State
 TCP  192.168.0.100:3049  192.168.0.88:7575    established
 TCP  192.168.0.100:3052  192.168.0.88:7575    established
 TCP  192.168.0.100:3061  192.168.0.88:7575    established

View your network configuration through the Ipconfig

PS c:\ps> ipconfig

Windows IP Configuration

Ethernet adapter Local area Connection:

  connection-specific DNS Suffix. : www.mossfly.com
  link-local IPv6 address ...: fe80::b9dd:91e33:33f0:7885%10 IPv4 address ....
  . . . . : 192.168.140.100
  Subnet Mask ...: 255.255.252.0
  Default Gateway .........:192.168.14. 0.1

Tunnel Adapter isatap.www.mossfly.com:

  connection-specific DNS Suffix.: www.mossfly.com
  link-local IPV6 address ...: fe80::5efe:192.168.140.100%11
  Default Gateway ...:

tunnel adapter tered, ... o Tunneling-Pseudo-Interface:

  Media State ...: Media disconnected
  connection-specific DNS Su Ffix. :

Route Print View routing information

PS c:\ps> Route print IPv4 Route Table =========================================================================== Active routes:network Destination Netmask Gateway Interface Metric 0.0.0.0 0.0.0.0 192.168.140.1 19     2.168.140.100 192.0.0.0 255.0.0.0 on-link 192.0.0.1 306 192.0.0.1 255.255.255.255 On-link 192.0.0.1 306 192.255.255.255 255.255.255.255 on-link 192.0.0.1 306 192.168.140.0 255.255.252.0 On-lin K 192.168.140.100 276 192.168.140.100 255.255.255.255 on-link 192.168.140.100 276 192.168.143.255.      255 On-link 192.168.140.100 276 224.0.0.0 240.0.0.0 on-link 192.0.0.1 306 224.0.0.0 240.0.0.0 On-link 192.168.140.100 276 255.255.255.255 255.255.255.255 on-link 192.0.0.1 306 255.255.255.255 255.25 5.255.255 on-link 192.168.140.100 276 =========================================================================== P Ersistent Routes:none IPv6 Route Table =========================================================================== Active routes:if Metric Network Destination Gateway 1 306:: 1/128 on-link A 276 fe80::/64 on-link one 281 fe80::5efe:192.16         8.140.100/128 On-link 276 fe80::b965:91f3:33a0:7285/128 on-link 1 306 ff00::/8 On-link 276 FF00::/8 On-link ========================================================================

 = = = Persistent Routes:none

Start the cmd console

Start the cmd console type cmd or cmd.exe, and exit cmd by command exit.

PS c:\ps> cmd
Microsoft Windows [Version 6.1.7601]
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

C:\ps>exit
PS c:\ps>

Find available cmd console commands

Cmd.exe through/C to receive command parameters, in CMD Help can see the available commands, so you can use CMD C help to find the available cmd console command

PS c:\ps> cmd/c Help For more information about a command, type help command name ASSOC display or modify the File name extension Association.
ATTRIB Display or change file properties.
Break set or clear an extended CTRL + C check.
BCDEDIT sets the properties in the startup database to control boot loading.
CACLS displays or modifies the Access Control List (ACL) for a file.
Call calls this one from another batch program.
The CD displays the name of the current directory or changes it.
CHCP Displays or sets the number of active code pages.
CHDIR displays the name of the current directory or changes it.
CHKDSK checks the disk and displays a status report.
CHKNTFS displays or modifies the boot time disk check.
The CLS clears the screen.
CMD opens another Windows command interpreter window.
Color sets the default console foreground and background color.
COMP compares the contents of two or two sets of files.
The compact displays or changes the compression of files on an NTFS partition. Convert converts a FAT volume to NTFS.
You cannot convert the current drive.
Copy copies at least one file to another location.
Date Displays or sets the dates.
DEL deletes at least one file.
DIR displays the files and subdirectories in a directory.
DISKCOMP compares the contents of two floppy disks.
DISKCOPY Copy the contents of one floppy disk to another floppy disk.
DISKPART displays or configures the disk partition properties.
DOSKEY Edit the command line, invoke Windows commands, and create macros.
DRIVERQUERY Displays current device driver status and properties.
ECHO displays the message, or turns the command back on or off.
Endlocal ends the localization of the environment changes in the batch file.
ERASE deletes one or more files. Exit CMD.
EXE Program (command interpreter).
FC compares two files or two sets of files and displays the differences between them.
Find searches for a text string in one or more files.
FINDSTR searches for strings in multiple files.
For running a specified command for each file in a set of files. Format the disk so that you can followWindows use.
FSUTIL displays or configures the properties of the file system.
FTYPE displays or modifies the file types that are associated with the file name extension.
GOTO points The Windows command interpreter to a tagged row in a batch program.
GPRESULT Displays Group Policy information for the machine or user.
GRAFTABL enables Windows to display extended character sets in graphical mode.
Help provides information about Windows commands.
Icacls to display, modify, back up, or restore ACLs on files and directories.
IF a conditional process is performed in a batch program.
LABEL creates, changes, or deletes a disk's volume label.
MD creates a directory.
MKDIR Create a directory.
Mklink Create symbolic links and hard link MODE to configure system devices.
More screen display output.
Move moves one or more files from one directory to another.
OPENFILES displays files that are opened by remote users for file sharing.
Path displays or sets the search path for the executable file.
PAUSE stops processing of batch files and displays information.
POPD restores the previous value of the current directory saved by PUSHD.
Print prints a text file.
PROMPT Change Windows command prompt.
PUSHD Save the current directory and make changes to it.
RD deletes the directory.
RECOVER to recover the readable information from the damaged disk. REM record batch file or CONFIG.
The comment in SYS.
REN Rename the file.
RENAME Rename the file.
Replace replaces the file.
RMDIR deletes the directory.
ROBOCOPY the advanced utility for copying files and trees displays, sets, or deletes Windows environment variables.
SETLOCAL began using batch files to change the localization of the environment.
SC Displays or configures services (background processing).
SCHTASKS schedule commands and programs to run on a computer on a scheduled basis.
SHIFT adjusts the position of the replaceable parameters in the batch file.
SHUTDOWN the machine to shut down properly locally or remotely.
Sort sorts the input. START OpenRun the specified program or command in a separate window.
SUBST associates the drive letter with the path.
SYSTEMINFO displays the specific properties and configuration of the machine.
TASKLIST displays all currently running tasks that include the service.
TASKKILL terminates a running process or application.
Time to display or set the system times. TITLE set CMD.
The window caption for the EXE session.
Tree graphically displays the directory structure of the initiator or path.
TYPE Displays the contents of the text file.
VER Displays the version of Windows.
VERIFY tells Windows to verify that the file is correctly written to disk.
VOL Displays the disk volume label and serial number.
XCOPY replicates files and directory trees.
 WMIC displays WMI information in the interactive command shell.

Start an external program

Why can I open Notepad through Notpad, and not open WordPad through WordPad?
Because Notepad.exe is located in the C:windows\system32 directory, this directory has been included in the PowerShell environment variable $env:path by default.

C:\WINDOWS\system32; C:\WINDOWS; C:\WINDOWS\System32\Wbem; C:\WINDOWS\System32\WindowsPowerShell\v1.0\; C:\Program Files (x
) \ Windows Kits\8.1\windows performance toolkit\; C:\Program Files\Microsoft SQL Server\110\tools\binn\; C:\Program File
S (x86) \microsoft Sdks\typescript\1.0\; C:\Program Files\microsoft\web Platform Installer\

and Wordpad.exe's "%ProgramFiles%\Windows Nt\accessories\wordpad.exe" directory is not included, you can first enter this directory, then run WordPad, or add the directory where the WordPad resides to the environment variable, $env:P ath= $env:P ath+ "%ProgramFiles%\Windows nt\accessories".

By default Type a string, PowerShell it out as it is, if the string is a command or launcher, add ' & ' before the string to execute the command, or start the program.

PS c:\ps> "ls"
ls
ps c:\ps> & "ls"

  directory:c:\ps

Mode        lastwritetime   Length Name
----        -------------   ----------
d----    2011/11/23   17:25      ABC-a
---    2011 /11/23   17:36     a.txt-a
---    2011/11/23   17:25     0 b.txt-a
---    2011/11/23   17:25     0 c.txt-a
---    2011/11/23   17:25     0 d.txt-a
---    2011/11/23   17:37    242 test.txt

PS c:\ps> "cmd.exe"
cmd.exe
PS c:\ps> & "cmd.exe"
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.