functionNew-CorporateUser { param ( [Parameter(Mandatory)] [string] ${Please provide a user name} )
$username = ${Please provide a user name} "You entered $Username" }
PS C:\> New-CorporateUser Cmdlet New-CorporateUser at command pipeline position 1 Supply values for the following parameters: Please provide a user name: Tobi You entered Tobi
它的副作用是参数名中含有空格和特殊字符,将使它无法通过命令行指定值,因为参数无法用双引号包起来:
1
PS C:\> New-CorporateUser-Please provide a user name
Show-Header Starting with this number: $number = 26443007 $number
Show-Header Display the bits for this number: $bits = [Convert]::ToString($number,2) $bits
Show-Header Add missing leading zeroes: # pad the string to its full bit range (32 bits) $bitsAligned = $bits.PadLeft(32, '0') $bitsAligned
Show-Header Display the four byte groups $bitsAligned-split'(?<=\G.{8})(?=.)'-join'-'
Show-Header Get the bytes by conversion to IPAddress object: $bytes = ([Net.IPAddress]$number).GetAddressBytes() $bytes
Show-Header Display the bits for the IPAddress bytes: $bitbytes = $bytes | ForEach-Object { [Convert]::ToString($_, 2).PadLeft(8,'0')} $bitbytes-join'-'
Show-Header Show the Least Significant Byte LSB: $bytes[0]
Show-Header Show LSB by turning the 8 bits to the right into a number to verify: $bits = [Convert]::ToString($number, 2) # take least significant bits [Convert]::toByte($bits.Substring($bits.Length-8),2)
Show-Header Show the Most Significant Byte MSB: $bytes[3]
===========================Starting with this number:===========================
26443007
=======================Display the bits for this number:========================
1100100110111110011111111
===========================Add missing leading Zeroes:==========================
00000001100100110111110011111111
==========================Display the four byte groups==========================
00000001-10010011-01111100-11111111
================Get the bytes by conversion to IPAddress object:================
255
124
147
1
===================Display the bits for the IPAddress bytes:====================
11111111-01111100-10010011-00000001
======================Show the Least Significant Byte LSB:======================
255
======Show LSB by turning the 8 bits to the right into a number to verify:======
255
=======================Show the Most Significant Byte MSB:======================
1