Re-Post: #SharePoint 2010 with Windows #PowerShell Remoting Step by Step
Enable Remoting support on SharePoint Server box
- Enable Windows PowerShell Remoting
- Increase memory limit for remote shell (Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000)
- Setup CredSSP support
Setup client machine for Remoting
- Enable CredSSP support
- Store and use credentials for scripting
A credential in Windows PowerShell is a object which contains username (as plain text) and password (as secure string).
First, use the following command to covert password from keyboard input to a secure string in a text file.
Read-Host -AsSecureString | ConvertFrom-SecureString | out-file C:\crd-sharepoint.txt
When you need to create a credential object, read this password (the secure string) from the file and create the credential with the following command:
$pwd = Get-Content C:\crd-sharepoint.txt | ConvertTo-SecureString
then create the credential (replace myusername with your domain\username):
$crd = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList "myusername",$pwd
Then you will be able to use this credential in the command line without any dialogue.
Enter-PSSession -ComputerName sharepoint.contoso.com -Authentication CredSSP -Credential $crd
3. Load SharePoint Windows PowerShell Snap-in
Add-PSSnapin Microsoft.SharePoint.Powershell
#Chess Kids
Interactive chess lessons, quizzes, games and puzzles for kids
Play chess against the computer
FREE online chess books for kids – download and print
Listing Execution Policies (#PowerShell)
In PowerShell v.2, there are multiple execution policies. You should use this to view and check the settings:
Get-ExecutionPolicy -List
Windows #PowerShell compiled Help for SharePoint Server 2010
http://go.microsoft.com/fwlink/?LinkId=179124
#PowerShell mathematical calculations
http://blogs.technet.com/heyscriptingguy/archive/2010/03/06/hey-scripting-guy-march-6-2010.aspx
The key to unlocking the ability of Windows PowerShell to create useful formulas is to leverage the static methods from the system.math class. You can easily see them by using the Get-Member cmdlet, as shown here:
PS C:\> [math] | Get-Member -Static | Format-Table name, membertype -AutoSize
Name MemberType
—- ———-
Abs Method
Acos Method
Asin Method
Atan Method
Atan2 Method
BigMul Method
Ceiling Method
Cos Method
Cosh Method
DivRem Method
Equals Method
Exp Method
Floor Method
IEEERemainder Method
Log Method
Log10 Method
Max Method
Min Method
Pow Method
ReferenceEquals Method
Round Method
Sign Method
Sin Method
Sinh Method
Sqrt Method
Tan Method
Tanh Method
Truncate Method
E Property
PI Property
Windows 2008 (R2) AD Cmdlets in #PowerShell
| Cmdlet | Description |
|---|---|
| Add-ADComputerServiceAccount | Adds one or more service accounts to an Active Directory computer. |
| Add-ADDomainControllerPasswordReplicationPolicy | Adds users, computers, and groups to the Allowed List or the Denied List of the read-only domain controller (RODC) Password Replication Policy (PRP). |
| Add-ADFineGrainedPasswordPolicySubject | Applies a fine-grained password policy to one more users and groups. |
| Add-ADGroupMember | Adds one or more members to an Active Directory group. |
| Add-ADPrincipalGroupMembership | Adds a member to one or more Active Directory groups. |
| Clear-ADAccountExpiration | Clears the expiration date for an Active Directory account. |
| Disable-ADAccount | Disables an Active Directory account. |
| Disable-ADOptionalFeature | Disables an Active Directory optional feature. |
| Enable-ADAccount | Enables an Active Directory account. |
| Enable-ADOptionalFeature | Enables an Active Directory optional feature. |
| Get-ADAccountAuthorizationGroup | Gets the Active Directory security groups that contain an account. |
| Get-ADAccountResultantPasswordReplicationPolicy | Gets the resultant password replication policy for an Active Directory account. |
| Get-ADComputer | Gets one or more Active Directory computers. |
| Get-ADComputerServiceAccount | Gets the service accounts that are hosted by an Active Directory computer. |
| Get-ADDefaultDomainPasswordPolicy | Gets the default password policy for an Active Directory domain. |
| Get-ADDomain | Gets an Active Directory domain. |
| Get-ADDomainController | Gets one or more Active Directory domain controllers, based on discoverable services criteria, search parameters, or by providing a domain controller identifier, such as the NetBIOS name. |
| Get-ADDomainControllerPasswordReplicationPolicy | Gets the members of the Allowed List or the Denied List of the RODC PRP. |
| Get-ADDomainControllerPasswordReplicationPolicyUsage | Gets the resultant password policy of the specified ADAccount on the specified RODC. |
| Get-ADFineGrainedPasswordPolicy | Gets one or more Active Directory fine-grained password policies. |
| Get-ADFineGrainedPasswordPolicySubject | Gets the users and groups to which a fine-grained password policy is applied. |
| Get-ADForest | Gets an Active Directory forest. |
| Get-ADGroup | Gets one or more Active Directory groups. |
| Get-ADGroupMember | Gets the members of an Active Directory group. |
| Get-ADObject | Gets one or more Active Directory objects. |
| Get-ADOptionalFeature | Gets one or more Active Directory optional features. |
| Get-ADOrganizationalUnit | Gets one or more Active Directory OUs. |
| Get-ADPrincipalGroupMembership | Gets the Active Directory groups that have a specified user, computer, or group. |
| Get-ADRootDSE | Gets the root of a domain controller information tree. |
| Get-ADServiceAccount | Gets one or more Active Directory service accounts. |
| Get-ADUser | Gets one or more Active Directory users. |
| Get-ADUserResultantPasswordPolicy | Gets the resultant password policy for a user. |
| Install-ADServiceAccount | Installs an Active Directory service account on a computer. |
| Move-ADDirectoryServer | Moves a domain controller in AD DS to a new site. |
| Move-ADDirectoryServerOperationMasterRole | Moves operation master (also known as flexible single master operations or FSMO) roles to an Active Directory domain controller. |
| Move-ADObject | Moves an Active Directory object or a container of objects to a different container or domain. |
| New-ADComputer | Creates a new Active Directory computer. |
| New-ADFineGrainedPasswordPolicy | Creates a new Active Directory fine-grained password policy. |
| New-ADGroup | Creates an Active Directory group. |
| New-ADObject | Creates an Active Directory object. |
| New-ADOrganizationalUnit | Creates a new Active Directory OU. |
| New-ADServiceAccount | Creates a new Active Directory service account. |
| New-ADUser | Creates a new Active Directory user. |
| Remove-ADComputer | Removes an Active Directory computer. |
| Remove-ADComputerServiceAccount | Removes one or more service accounts from a computer. |
| Remove-ADDomainControllerPasswordReplicationPolicy | Removes users, computers, and groups from the Allowed List or the Denied List of the RODC PRP. |
| Remove-ADFineGrainedPasswordPolicy | Removes an Active Directory fine-grained password policy. |
| Remove-ADFineGrainedPasswordPolicySubject | Removes one or more users from a fine-grained password policy. |
| Remove-ADGroup | Removes an Active Directory group. |
| Remove-ADGroupMember | Removes one or more members from an Active Directory group. |
| Remove-ADObject | Removes an Active Directory object. |
| Remove-ADOrganizationalUnit | Removes an Active Directory OU. |
| Remove-ADPrincipalGroupMembership | Removes a member from one or more Active Directory groups. |
| Remove-ADServiceAccount | Removes an Active Directory service account. |
| Remove-ADUser | Removes an Active Directory user. |
| Rename-ADObject | Changes the name of an Active Directory object. |
| Reset-ADServiceAccountPassword | Resets the service account password for a computer. |
| Restore-ADObject | Restores an Active Directory object. |
| Search-ADAccount | Gets Active Directory user, computer, and service accounts. |
| Set-ADAccountControl | Modifies user account control (UAC) values for an Active Directory account. |
| Set-ADAccountExpiration | Sets the expiration date for an Active Directory account. |
| Set-ADAccountPassword | Modifies the password of an Active Directory account. |
| Set-ADComputer | Modifies an Active Directory computer. |
| Set-ADDefaultDomainPasswordPolicy | Modifies the default password policy for an Active Directory domain. |
| Set-ADDomain | Modifies an Active Directory domain. |
| Set-ADDomainMode | Sets the domain functional level for an Active Directory domain. |
| Set-ADFineGrainedPasswordPolicy | Modifies an Active Directory fine-grained password policy. |
| Set-ADForest | Modifies an Active Directory forest. |
| Set-ADForestMode | Sets the forest mode for an Active Directory forest. |
| Set-ADGroup | Modifies an Active Directory group. |
| Set-ADObject | Modifies an Active Directory object. |
| Set-ADOrganizationalUnit | Modifies an Active Directory OU. |
| Set-ADServiceAccount | Modifies an Active Directory service account. |
| Set-ADUser | Modifies an Active Directory user. |
| Uninstall-ADServiceAccount | Uninstalls an Active Directory service account from a computer. |
| Unlock-ADAccount | Unlocks an Active Directory account. |
#Fitnesse;#PowerSlim;Test-Path
Good news:) With Fitnesse + PowerSlim the problem described here can be solved gracefully. You can use Test-Path PowerShell CMDlet:
!|script|PowerShell|
|check|eval|Test-Path "C:\ExportEmpty\*"|False|
|check|eval|Test-Path "c:\ExportNotEmpty\*"|True|
Query File lines
With powerslim you can Query a file.
!|script|PowerShell|
|eval |!-function get_lines($file){Get-Content $file | % {New-Object PSObject -Property @{Line=$_}}}-!|
!|Query:PowerShell|get_lines c:\myfile.txt|
|Line|
|text at first line|
|text at second line|
Power Fitnesse (One Fitnesse against multiple VMs via PowerShell 2.0)
Check this interesting post from Mike. You will find an idea how to specify credentials w/o promt for PowerShell remote command execution. This is the common thing for the “Power Fitnesse”
http://maplpro.blogspot.com/2010/03/powershell-20-plus-fitnesse-slim-plus.html