PowerShell use tips to share _powershell

Source: Internet
Author: User

How to use PowerShell to modify a host file

The following command adds a record to the host file and lets/sps2010/hostheader1/this URL point to the server itself.

Copy Code code as follows:

$url = "http://sps2010/hostheader1/"
if (get-content $env: windir\system32\drivers\etc\hosts |? {$_-imatch "\s$url"}) -eq $null) {"' n127.0.0.1 $url" | Out-file-filepath "$env: Windir\system32\drivers\etc\hosts"-append-encoding ASCII}

A PowerShell method call

No time system of learning PowerShell, can only now learn to use. This function call took me more than half an hour to finish. Oh.
You don't laugh at me, hehe.

In this example, the following points are included in the PowerShell:

method of calling static functions
The specified method of the enumeration type
Null value
Boolean value

 
PS C:\Users\administrator. vsat> $SPUtility = [Microsoft.Sharepoint.Utilities.SPUtility] 
PS C:\Users\administrator. vsat> $SPPrincipalType = [Microsoft.Sharepoint.Utilities.SPPrincipalType]
PS C:\Users\administrator. Vsat> $obj = $SPUtility:: Resolvewindowsprincipal ($null, $owebapp, "Vsat\administrator", $SPPrincipalType:: user,$ False) 
PS C:\Users\administrator. vsat> $obj

principaltype   : User 
LoginName     : Vsat\administrator 
issharepointgroup:false 
principalid    :-1 
Email       : Administrator@vsat.bizapp 
sipaddress    : 
Mobile      : 
DisplayName:    Administrator 
Department    : 
jobtitle     :

How do I determine the current version of PowerShell?

Run the following command:

Get-host | Select-object Version

If the installation is PowerShell 3.0, then the output should be:

Version
-------
3.0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.