-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #652 from PowerShell/release-1.9
Release 1.9
- Loading branch information
Showing
93 changed files
with
1,428 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
Modules/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.psm1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[parameter(Mandatory = $false)] | ||
[System.Management.Automation.PSCredential] | ||
$InstallAccount, | ||
|
||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$ManagedAccount | ||
) | ||
|
||
Write-Verbose -Message "Getting identity for service instance '$Name'" | ||
|
||
$result = Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
|
||
$serviceInstance = Get-SPServiceInstance -Server $env:computername | Where-Object { $_.TypeName -eq $params.Name } | ||
|
||
if ($null -eq $serviceInstance.service.processidentity) | ||
{ | ||
Write-Verbose "WARNING: Service $($params.name) does not support setting the process identity" | ||
} | ||
|
||
$ManagedAccount = $serviceInstance.service.processidentity.username | ||
|
||
return @{ | ||
Name = $params.Name | ||
ManagedAccount = $ManagedAccount | ||
} | ||
|
||
} | ||
|
||
return $result | ||
|
||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[parameter(Mandatory = $false)] | ||
[System.Management.Automation.PSCredential] | ||
$InstallAccount, | ||
|
||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$ManagedAccount | ||
) | ||
|
||
Write-Verbose -Message "Setting service instance '$Name' to '$ManagedAccount'" | ||
|
||
Invoke-SPDSCCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
|
||
$serviceInstance = Get-SPServiceInstance -Server $env:COMPUTERNAME| Where-Object { $_.TypeName -eq $params.Name } | ||
$managedAccount = Get-SPManagedAccount $params.ManagedAccount | ||
if ($null -eq $serviceInstance) | ||
{ | ||
throw [System.Exception] "Unable to locate service $($params.Name)" | ||
} | ||
if ($null -eq $managedAccount) | ||
{ | ||
throw [System.Exception] "Unable to locate Managed Account $($params.ManagedAccount)" | ||
} | ||
|
||
if ($null -eq $serviceInstance.service.processidentity) | ||
{ | ||
throw [System.Exception] "Service $($params.name) does not support setting the process identity" | ||
} | ||
|
||
$serviceInstance.service.processIdentity.CurrentIdentityType = [Microsoft.SharePoint.Administration.IdentityType]::SpecificUser | ||
$serviceInstance.service.processIdentity.ManagedAccount = $managedAccount | ||
$serviceInstance.service.processIdentity.update() | ||
$serviceInstance.service.processIdentity.deploy() | ||
|
||
} | ||
|
||
|
||
} | ||
|
||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$Name, | ||
|
||
[parameter(Mandatory = $false)] | ||
[System.Management.Automation.PSCredential] | ||
$InstallAccount, | ||
|
||
[parameter(Mandatory = $true)] | ||
[System.String] | ||
$ManagedAccount | ||
) | ||
|
||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
Write-Verbose -Message "Testing service instance '$Name' Process Identity" | ||
|
||
return ($CurrentValues.ManagedAccount -eq $ManagedAccount) | ||
|
||
|
||
} |
7 changes: 7 additions & 0 deletions
7
Modules/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/MSFT_SPServiceIdentity.schema.mof
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ClassVersion("1.0.0.0"), FriendlyName("SPServiceIdentity")] | ||
class MSFT_SPServiceIdentity : OMI_BaseResource | ||
{ | ||
[Key, Description("The name of the service instance to manage")] string Name; | ||
[Required, Description("The user name of a managed account that will be used to run the service") ] string ManagedAccount; | ||
[Write, Description("POWERSHELL 4 ONLY: The account to run this resource as, use PsDscRunAsAccount if using PowerShell 5"), EmbeddedInstance("MSFT_Credential")] String InstallAccount; | ||
}; |
6 changes: 6 additions & 0 deletions
6
Modules/SharePointDsc/DSCResources/MSFT_SPServiceIdentity/readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Description | ||
|
||
This resource is used to specify a managed account to be used to run a service instance. | ||
The name is the typename of the service as shown in the Central Admin website. | ||
This resource only needs to be run on one server in the farm, as the process identity | ||
update method will apply the settings to all instances of the service. |
26 changes: 26 additions & 0 deletions
26
Modules/SharePointDsc/Examples/Resources/SPServiceIdentity/1-Example.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<# | ||
.EXAMPLE | ||
This example shows how to set the SandBox Code Service to run under a specifed service account. | ||
The account must already be registered as a managed account. | ||
#> | ||
|
||
Configuration Example | ||
{ | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[PSCredential] | ||
$SetupAccount | ||
) | ||
|
||
Import-DscResource -ModuleName SharePointDsc | ||
|
||
node localhost { | ||
|
||
SPServiceIdentity SandBoxUserAccount | ||
{ | ||
Name = "Microsoft SharePoint Foundation Sandboxed Code Service" | ||
ManagedAccount = "CONTOSO\SPUserCode" | ||
PsDscRunAsCredential = $SetupAccount | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<# | ||
.SYNOPSIS | ||
The New-SPDscAzureLab cmdlet will create a new environment in Azure that can be used to develop | ||
for SharePointDsc or to run integration tests against | ||
.DESCRIPTION | ||
The New-SPDscAzureLab cmdlet will deploy a new resource group in to your current Azure subscription | ||
that will contain storage, network and virtual machines that are configured to be able to begin | ||
development. Appropriate development tools are also installed on the SharePoint server. | ||
.PARAMETER ResourceGroupName | ||
The name of the resource group to create and deploy assets in to. This cannot be an existing | ||
resource group | ||
.PARAMETER Location | ||
The Azure location to deploy the assets and resource group to. To discover Azure locations run | ||
Get-AzureRmLocation | Select-Object -Property Location | ||
.PARAMETER StorageAccountName | ||
This is the name of the storage account that will be created for the deployment. This will | ||
contain VHD images, scripts and DSC configurations | ||
.PARAMETER SoftwareStorageAccountName | ||
This is the name of a storage account that will contain the binaries for SharePoint Server | ||
(either 2013 or 2016). | ||
.PARAMETER SoftwareStorageAccountContainer | ||
This is the name of the container in the software storage account that will contain the | ||
binaries for the version of SharePoint you wish to deploy. This must be the full set of | ||
files to install SharePoint (not an ISO or other compressed collection of the files) | ||
.PARAMETER SharePointProductKey | ||
A valid product key for the version of SharePoint you wish to install | ||
.PARAMETER PublicDNSLabel | ||
The name of the public DNS label to assign to the public IP address of the SharePoint server. | ||
This will automatically be suffixed with the Azure location name and azure DNS suffix | ||
.PARAMETER AdminCredential | ||
The username and password to use as the local administrator on all machines. The password | ||
on this account will also be used for all service accounts | ||
.EXAMPLE | ||
New-SPDscAzureLab -ResourceGroupName "SPDSCTestLab" ` | ||
-Location southeastasia ` | ||
-StorageAccountName "spdsctestlab1" ` | ||
-SoftwareStorageAccountName "spdscsoftware1" ` | ||
-SoftwareStorageAccountContainer "sharepoint2016" ` | ||
-SharePointProductKey "AAAAA-AAAAA-AAAAA-AAAAA-AAAAA" ` | ||
-PublicDNSLabel "spdsctestlab1" ` | ||
-AdminCredential (Get-Credential -Message "Enter admin credential") | ||
.NOTES | ||
This cmdlet requires that the Azure PowerShell cmdlets are already installed, and that you | ||
have already run Login-AzureRmAccount to log in to Azure | ||
#> | ||
function New-SPDscAzureLab | ||
{ | ||
param( | ||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$ResourceGroupName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$Location, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$StorageAccountName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$SoftwareStorageAccountName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$SoftwareStorageAccountContainer, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$SharePointProductKey, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[string] | ||
$PublicDNSLabel, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[PSCredential] | ||
$AdminCredential | ||
) | ||
|
||
# Create the RG and storage account | ||
New-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location | ||
$storageAccount = New-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName ` | ||
-Name $StorageAccountName ` | ||
-SkuName Standard_LRS ` | ||
-Location $Location | ||
|
||
# Publish the DSC configurations | ||
$dscConfigPath = Join-Path -Path $PSScriptRoot -ChildPath "DscConfigs" | ||
Get-ChildItem -Path $dscConfigPath | ForEach-Object -Process { | ||
Publish-AzureRmVMDscConfiguration -ConfigurationPath $_.FullName ` | ||
-ResourceGroupName $ResourceGroupName ` | ||
-StorageAccountName $StorageAccountName | ||
} | ||
|
||
# Publish the scripts | ||
New-AzureStorageContainer -Name "scripts" -Context $storageAccount.Context | ||
$scriptsPath = Join-Path -Path $PSScriptRoot -ChildPath "CustomScripts" | ||
Get-ChildItem -Path $scriptsPath | ForEach-Object -Process { | ||
Set-AzureStorageBlobContent -File $_.FullName ` | ||
-Container "scripts" ` | ||
-Blob $_.Name ` | ||
-Context $storageAccount.Context | ||
} | ||
|
||
# Get Sas token for DSC storage | ||
$mainKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $ResourceGroupName ` | ||
-Name $StorageAccountName | ||
$mainStorageContext = New-AzureStorageContext -StorageAccountName $StorageAccountName ` | ||
-StorageAccountKey $mainKeys[0].Value | ||
$mainSasToken = New-AzureStorageAccountSASToken -Service Blob ` | ||
-ResourceType Service,Container,Object ` | ||
-Permission "racwdlup" ` | ||
-Context $mainStorageContext | ||
|
||
# Get keys for software storage | ||
$storageAccount = Find-AzureRmResource -ResourceNameContains $SoftwareStorageAccountName | ||
$softwareKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccount.ResourceGroupName ` | ||
-Name $SoftwareStorageAccountName | ||
|
||
|
||
$parameters = @{} | ||
$parameters.Add("storageAccountName", $StorageAccountName) | ||
$parameters.Add("storageAccountKey", $mainKeys[0].Value) | ||
$parameters.Add("softwareStorageAccount", $SoftwareStorageAccountName) | ||
$parameters.Add("softwareStorageKey", $softwareKeys[0].Value) | ||
$parameters.Add("softwareStorageContainer", $SoftwareStorageAccountContainer) | ||
$parameters.Add("spProductKey", $SharePointProductKey) | ||
$parameters.Add("adminUserName", $AdminCredential.UserName) | ||
$parameters.Add("adminPassword", $AdminCredential.GetNetworkCredential().Password) | ||
$parameters.Add("mainStorageToken", $mainSasToken) | ||
$parameters.Add("publicDnsLabel", $PublicDNSLabel) | ||
|
||
# Start the ARM deployment | ||
$templatePath = Join-Path -Path $PSScriptRoot -ChildPath "template.json" | ||
New-AzureRmResourceGroupDeployment -Name "SPDscLab" ` | ||
-TemplateFile $templatePath ` | ||
-ResourceGroupName $ResourceGroupName ` | ||
-TemplateParameterObject $parameters ` | ||
-Verbose | ||
} | ||
|
||
Export-ModuleMember -Function * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
$packageProviderName = "ChocolateyGet" | ||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | ||
Install-PackageProvider -Name $packageProviderName | ||
Import-PackageProvider -Name $packageProviderName | ||
|
||
$packages = @( | ||
"visualstudiocode" | ||
"nodejs" | ||
"git" | ||
"Git-Credential-Manager-for-Windows" | ||
"poshgit" | ||
) | ||
|
||
$packages | ForEach-Object -Process { | ||
Install-Package -Name $_ -ProviderName $packageProviderName -Confirm:$false -Force | ||
} |
Oops, something went wrong.