Windows PowerShell is a command-line shell and scripting environment that will likely replace the command prompt (CMD) in the future. In the Windows 10 system, many users are relatively unfamiliar with PowerShell, so today Xiaobian introduces 15 common PowerShell advanced tasks.
15 PowerShell advanced tasks commonly used in Windows 10:
1, open the PowerShell environment
Windows 10 has built-in PowerShell command line environment, you can directly search for "PowerShell And run as an administrator.
Or type PowerShell in the search bar and search with Ctrl + Shift + Enter.
2, set the date and time
There are many ways to set the time and date of the Windows system, but using PowerShell should be said to be the quickest way, just like the following command Can:
Set-Date -date “2016-12-01 8:30 AM”
AM and PM believe that there is no need to explain it.
3, adjust the date and time
In some special cases, we may need to adjust the date and time instead of directly specifying the specific value, to complete this task or use the Set-Date cmdlet , but the usage is different from the previous ones, for example:
Set-Date (Get-Date).AddDays(2)
From the above command you can see that we first pass Get -Date Gets the current date and then triggers Set-Date to add 2 to the date. Of course, this command can also use AddHours, AddMinutes or AddSeconds to increase the time, minute, second, etc. for the time.
4, verify files and folders
PowerShell command can easily check whether a file and folder exist on the computer, use the Test-Path cmdlet and then follow the path to complete the verification. No need to spend time looking in the resource manager. For example, to verify that the C drive has an Excel file named PowerShell.xlsx, you can use the following command:
Test-Path c:\\PowerShell.xlsx
This command returns True or False such as False, if you don't know the exact file name, you can also use wildcards directly, for example:
Test-Path c:\\*.xlsx
5. Rename the file and Folders
Once you know the exact path to the filename folder, PowerShell can also easily rename files and folders. Just use the Rename-Item cmdlet with the following example:
Rename-Item c:\\PowerShell.xlsx New_PowerShell.xlsx
6. Moving files and folders
It's also very easy to move files or folders using PowerShell, using the Move-Item cmdlet , for example:
Move-Item c:\\PowerShell.xlsx d:\\PowerShell.xlsx
Combine wildcards to quickly move certain types of files from one folder to another Clip:
Move-Item c :\\*.xls d:\\excel\\
7. Open the program
The Invoke-Item cmdlet can open the application directly from the PowerShell prompt:
Invoke-Item c:\\Windows\\System32\ otepad.exe
However, applications that are already in the Windows Path path can be executed directly by name, for example:
notepad
8. Using the default Program Open File
The Invoke-Item cmdlet can be used to open a file directly, in addition to executing the application. But everyone needs to be aware that when you use it to open a file, it will only be opened with the default application associated with that file type.
Invoke-Item c:\\Sysgeek\\Hello.txt
9. Open the file as a batch
When the Invoke-Item cmdlet is combined with a wildcard, you can open it in batches A type of file:
Invoke-Item c:\\Sysgeek\\*.txt
10, read text file
PowerShell can directly handle the contents of text files, For example, you can read the contents of a text file using the Get-Content command:
Get-Content c:\\Sysgeek\\Hello.txt
If you just want to preview the file instead of reading the entire text, You can use the -totalcount parameter:
Get-Content c:\\Sysgeek\\Hello.txt -totalcount 1
11. Add text content
In addition to reading text file content Use the Add-Content cmdlet in PowerShell to add content directly:
Add-Content c:\\Sysgeek\\Hello.txt "by Sea Monkey"
Of course, this command will only Appending text to the end of the file does not necessarily meet your needs.
12, statistical text files
Whether you want to count ordinary files, or want to count how many lines of code written in a day, you can use the following command:
Get- Content c:\\Sysgeek\\Hello.txt
After the disk has been used for a long time, it will produce a lot of fragmentatio
Microsoft today sent an email to the Windows Insider user community to share more information about
Previously, some netizens asked online: How to uninstall 360 security guards under
In Windows 10, we need to log in to the account every time it runs. It is too incon
Windows 10 system Windows Defender can not start the repair method
How does Win10 modify the update download method to speed up the download speed
What should I do if the win10 browser is always open? The
Win10 solves the high disk usage by uninstalling the driver.
How to uninstall win10 KB3132372 patch?
How to turn on or off the built-in positioning function in Win10
Win10 system update patch error 80070643 processing method
What should I do if the Win10 system control panel cannot be opened?
Win10 mobile phone preview version and WP8.1 system UI multi-image comparison
The Win10 system hides the toolbar icon in the lower right corner of the desktop. Step
Win10 does not return to the desktop to directly launch the desktop program
When upgrading Win10 11082 to copy files, I can't find the progress bar window. What happened?
Win7 appears yellow exclamation point can not access the Internet how to do
Windows10 uses commands to view laptop battery status
Win7 system can not find the compatibility tab how to solve
Usage of Linux global variable jiffies
Win10 fault repair: win10 can not activate the prompt 0xc0ea000a error how to do?
Win8 turns on and off system restore protection function
Win8 Phone Activation Detailed Guide
How does WinXP reset the TCP/IP protocol?