Windows PowerShell Commands

论坛 期权论坛 脚本     
匿名技术用户   2021-1-4 03:01   429   0

Intro

This page records some Windows PowerShell commands.

Print the full path name of specific file

We can get the full path name with "ls" fullname command. Here are the command and command output.

//List all the files
PS C:\gitroot\test_tools\taef_tests\WavTest> (ls -r).fullname
C:\gitroot\test_tools\taef_tests\WavTest\build
C:\gitroot\test_tools\taef_tests\WavTest\WavPlayTest
C:\gitroot\test_tools\taef_tests\WavTest\build_with_testcert.bat
C:\gitroot\test_tools\taef_tests\WavTest\WavTest.sln
C:\gitroot\test_tools\taef_tests\WavTest\build\build.proj

//List specific file
PS C:\gitroot\test_tools\taef_tests\WavTest> (ls .\WavTest.sln).fullname
C:\gitroot\test_tools\taef_tests\WavTest\WavTest.sln

Convert Decimal <==> Hexadecimal

Use format string with the Windows PowerShell format (-f) operator.

Standard Numeric Format Strings

Hexadecimal to Decimal

PS C:\github> 0x90
144
PS C:\github> '{0:d}' -f 0x90
144

Decimal to Hexadecimal

PS C:\github> '{0:x}' -f 144
90
PS C:\github> '{0:x}' -f 255
ff

Arithmetic Operators

PowerShell About Arithmetic Operators

PS C:\github> 1152/144
8

About Environment Variables

About Environment Variables for PowerShell.

The PowerShell environment provider lets you access Windows environment variables in PowerShell in a PowerShell drive (the Env: drive). This drive looks much like a file system drive.

Get-ChildItem Env:

Get-ChildItem: Gets the items and child items in one or more specified locations.

You can also refer to Get-ChildItem by its built-in aliases, ls, dir, and gci.

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP