Identify 64-bit Environments
Identifying 64-bit-environments
Http://powershell.com/cs/blogs/tips/archive/2010/09/20/identifying-64-bit-environments.aspx
Determine the length of the variable type intptr. If it is 8, it is a 64-bit system, and 4 is a 32-bit system.
If ([intptr]: Size-EQ 8) {"Ein 64-bit-System"} else {"Ein 32-bit-System "}
Static Search Method
Finding static methods
Http://powershell.com/cs/blogs/tips/archive/2010/09/21/finding-static-methods.aspx
A type usually contains many useful methods. You can use get-member to display all of them, and use the-static parameter to view all static methods. If you do not add a static method, you can only view the instance method:
[Datetime] | get-member-static
[Datetime]: isleapyear (2010)
Prompt for Password
Prompting for passwords
Http://powershell.com/cs/blogs/tips/archive/2010/09/22/prompting-for-passwords.aspx
The get-credential method prompts you to enter the password on a visual interface. This method returns a credential object containing the encrypted password. Only the getnetworkcredential method can be used to view the plaintext information:
$ Cred = Get-credential someusername
$ Cred. Password
# Here the information is encrypted
$ Cred. getnetworkcredential ()
# Using this method, you can return its plaintext Information
$ Cred. getnetworkcredential (). Password
# And plaintext passwords
The console prompts you to enter the password
Prompting for secret passwords via console with powershell
Http://powershell.com/cs/blogs/tips/archive/2010/09/23/prompting-for-secret-passwords-via-console-with-powershell.aspx
You can use the read-host method to hide the password entered by the user:
$ Pwd = read-host-assecurestring 'enter password'
The password is saved in encrypted mode. To view the plaintext information, you only need to convert it into a credential object:
(New-Object System. Management. Automation. pscredential ('dummy', $ PWD). getnetworkcredential (). Password
Enter the password through the console prompt
Prompting for secret passwords via console
Http://powershell.com/cs/blogs/tips/archive/2010/09/24/prompting-for-secret-passwords-via-console.aspx
Use a low-level ps api:
$ C = $ host. UI. promptforcredential ('Log on', $ null, 'test \ user', 'target ')
$ C
This method allows you to define information such as the title of the dialog box.
Retrieve subtitle list
Getting alphabetical listings
Http://powershell.com/cs/blogs/tips/archive/2010/09/13/getting-alphabetical-listings.aspx
Using the... method, powershell only supports the number type, for example:
1. 10
But here we can achieve this through the type conversion method:
$ OFS = ","
[String] [char [] (65 .. 90)
In this way, you can obtain a list from A to Z.
Get short date type
Getting short dates
Http://powershell.com/cs/blogs/tips/archive/2010/09/14/getting-short-dates.aspx
This article describes how to use the methods in objects.
(Get-date). tow.datestring ()
Actually, it is the CLR method.
In addition, you can view all supported methods:
Get-date | get-member-membertype * Method
Search for a leap year
Finding leap years
Http://powershell.com/cs/blogs/tips/archive/2010/09/15/finding-leap-years.aspx
The date type contains many useful static methods. For example, you can check whether the specified year is a leap year:
[Datetime]: isleapyear (1904)
View the number of days in a month
Finding days in month
Http://powershell.com/cs/blogs/tips/archive/2010/09/16/finding-days-in-month.aspx
It is implemented through static method of date type, for example:
[Datetime]: daysinmonth (2009, 2)
# Result: 28
[Datetime]: daysinmonth (2008, 2)
# Result: 29
View the maximum value
Finding maximum values
Http://powershell.com/cs/blogs/tips/archive/2010/09/17/finding-maximum-values.aspx
There is a range for digital storage. For example, if the range of a byte storage is 0 to 255, what about int32 and int64? You can use powershell:
[Int32]: maxvalue
# Result: 2147483647
[Int64]: maxvalue
# Result: 9223372036854775807
[Byte]: maxvalue
# Result: 255
You can also see the differences between the unsigned types through this method:
[Int32]: maxvalue
2147483647
[Uint32]: maxvalue
4294967295
[Int32]: minvalue
-2147483648
[Uint32]: minvalue
0
Because the unsigned number does not exist, the maximum value is twice the value of the signed type.
FromPowershell.com
2010From October 13 to 24Powertip of the day