Windows PowerShell Commands

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, lsdir, and gci.

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值