Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial #1

Merged
merged 1 commit into from
Nov 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
190 changes: 190 additions & 0 deletions Modules/Office365DSC/DSCResources/MSFT_SPOSite/MSFT_SPOSite.psm1
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
function Get-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$Url,

[Parameter(Mandatory = $true)]
[System.String]
$Owner,

[Parameter(Mandatory = $true)]
[System.UInt32]
$StorageQuota,

[Parameter()]
[System.String]
$Title,

[Parameter()]
[System.UInt32]
$CompatibilityLevel,

[Parameter()]
[System.UInt32]
$LocaleId,

[Parameter()]
[System.Double]
$ResourceQuota,

[Parameter()]
[System.String]
$Template,

[Parameter()]
[System.UInt32]
$TimeZoneId,

[Parameter(Mandatory = $true)]
[System.String]
$CentralAdminUrl,

[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$GlobalAdminAccount
)

Write-Verbose -Message "Connecting to SharePoint Online $CentralAdminUrl"
Connect-SPOService -Url $CentralAdminUrl -Credential $GlobalAdminAccount

Write-Verbose -Message "Getting site collection $Url"

$site = Get-SPOSite

$nullReturn = @{
Url = $null
Owner = $null
}

return @{
Url = $site.Url
Owner = $site.Owner
CompatibilityLevel = $site.CompatibilityLevel
Language = $site.RootWeb.Language
Title = $site.Title
}
}

function Set-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$Url,

[Parameter(Mandatory = $true)]
[System.String]
$Owner,

[Parameter(Mandatory = $true)]
[System.UInt32]
$StorageQuota,

[Parameter()]
[System.String]
$Title,

[Parameter()]
[System.UInt32]
$CompatibilityLevel,

[Parameter()]
[System.UInt32]
$LocaleId,

[Parameter()]
[System.Double]
$ResourceQuota,

[Parameter()]
[System.String]
$Template,

[Parameter()]
[System.UInt32]
$TimeZoneId,

[Parameter(Mandatory = $true)]
[System.String]
$CentralAdminUrl,

[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$GlobalAdminAccount
)

Write-Verbose -Message "Connecting to SharePoint Online $CentralAdminUrl"
Connect-SPOService -Url $CentralAdminUrl -Credential $GlobalAdminAccount

Write-Verbose -Message "Setting site collection $Url"

New-SPOSite -Url $Url -Owner $Owner -StorageQuota $StorageQuota -Title $Title
}

function Test-TargetResource
{
[CmdletBinding()]
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter(Mandatory = $true)]
[System.String]
$Url,

[Parameter(Mandatory = $true)]
[System.String]
$Owner,

[Parameter(Mandatory = $true)]
[System.UInt32]
$StorageQuota,

[Parameter()]
[System.String]
$Title,

[Parameter()]
[System.UInt32]
$CompatibilityLevel,

[Parameter()]
[System.UInt32]
$LocaleId,

[Parameter()]
[System.Double]
$ResourceQuota,

[Parameter()]
[System.String]
$Template,

[Parameter()]
[System.UInt32]
$TimeZoneId,

[Parameter(Mandatory = $true)]
[System.String]
$CentralAdminUrl,

[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$GlobalAdminAccount
)

Write-Verbose -Message "Testing site collection $Url"

$CurrentValues = Get-TargetResource @PSBoundParameters

return ($Title -eq $CurrentValues.Title)
}

Export-ModuleMember -Function *-TargetResource
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[ClassVersion("1.0.0.0"), FriendlyName("SPOSite")]
class MSFT_SPOSite : OMI_BaseResource
{
[Key, Description("The URL of the site collection")] string Url;
[Required, Description("The username of the site collection administrator")] string Owner;
[Required, Description("The resource quota to apply to the site collection")] uint32 StorageQuota;
[Write, Description("The title of the site")] string Title;
[Write, Description("The compatibility level of the site")] uint32 CompatibilityLevel;
[Write, Description("The locale code of the site")] uint32 LocaleId;
[Write, Description("The resource quota to apply to the site collection")] uint32 ResourceQuota;
[Write, Description("The template to apply to the site collection")] string Template;
[Write, Description("Id ot the Timezone to assign to this site collection")] uint32 TimeZoneId;
[Write, Description("The Url of the SharePoint Online Central Administration")] string CentralAdminUrl;
[Required, Description("Credentials of the SharePoint Global Admin"), EmbeddedInstance("MSFT_Credential")] string GlobalAdminAccount;
};

29 changes: 29 additions & 0 deletions Modules/Office365DSC/DSCResources/MSFT_SPOSite/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Description

**Type:** Distributed
**Requires CredSSP:** No

This resource will provision a site collection to the current farm, based on
the settings that are passed through. These settings map to the New-SPSite
cmdlet and accept the same values and types.

The current version of SharePointDsc is only able to check for the existence
of a site collection, the additional parameters are not checked for yet, but
will be in a later release

NOTE:
When creating Host Header Site Collections, do not use the HostHeader
parameter in SPWebApplication. This will set the specified host header on your
IIS site and prevent the site from listening for the URL of the Host Header
Site Collection.
If you want to change the IIS website binding settings, please use the xWebsite
resource in the xWebAdministration module.

NOTE2:
The CreateDefaultGroups parameter is only used for creating default site
groups. It will not remove or change the default groups if they already exist.

NOTE3:
AdministrationSiteType is used in combination with the resource
SPWebAppClientCallableSettings. The required proxy library must be configured
before the administration site type has any effect.
28 changes: 28 additions & 0 deletions Modules/Office365DSC/Examples/ProofOfConcept.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Configuration ProofOfConcept
{
Import-DSCResource -ModuleName Office365DSC -ModuleVersion 1.0.0.0
$credsGlobalAdmin = Get-Credential -UserName "[email protected]" -Message "Global Admin"
Node localhost
{
SPOSite TestNik
{
Url = "https://O365DSC1.sharepoint.com/sites/PoC"
Owner = "[email protected]"
StorageQuota = 1000
Title = "ProofOfConcept"
CentralAdminUrl = "https://o365dsc1-admin.sharepoint.com"
GlobalAdminAccount = $credsGlobalAdmin
}
}
}

$configData = @{
AllNodes = @(
@{
NodeName = "localhost"
PSDscAllowPlainTextPassword = $true;
PSDscAllowDomainUser = $true;
}
)
}
ProofOfConcept -ConfigurationData $configData
Binary file not shown.
116 changes: 116 additions & 0 deletions Modules/Office365DSC/Office365DSC.psd1
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#
# Module manifest for module 'Office365DSC'
#
# Generated by: Microsoft Corporation
#
# Generated on: 21/11/2018
#

@{

# Script module or binary module file associated with this manifest.
# RootModule = ''

# Version number of this module.
ModuleVersion = '1.0.0.0'

# ID used to uniquely identify this module
GUID = '6c1176a0-4fac-4134-8ca2-3fa8a21a7b90'

# Author of this module
Author = 'Microsoft Corporation'

# Company or vendor of this module
CompanyName = 'Microsoft Corporation'

# Copyright statement for this module
Copyright = '(c) 2018 Microsoft Corporation. All rights reserved.'

# Description of the functionality provided by this module
Description = 'This DSC module is used to configure and monitor Office365 tenants, including SharePoint Online, Exchange, Teams, etc.'

# Minimum version of the Windows PowerShell engine required by this module
PowerShellVersion = '5.1'

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
NestedModules = @()

# Functions to export from this module
#FunctionsToExport = '*'

# Cmdlets to export from this module
CmdletsToExport = @("")

# Variables to export from this module
#VariablesToExport = '*'

# Aliases to export from this module
#AliasesToExport = '*'

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -prefix.
# DefaultCommandPrefix = ''

# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{

PSData = @{

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @('DesiredStateConfiguration', 'DSC', 'DSCResourceKit', 'DSCResource', 'Office365')

# A URL to the license for this module.
LicenseUri = 'https://github.com/Microsoft/Office365/blob/master/LICENSE'

# A URL to the main website for this project.
ProjectUri = 'https://github.com/Microsoft/Office365'

# A URL to an icon representing this module.
# IconUri = ''

# ReleaseNotes of this module
ReleaseNotes = "
* Initial Release"
} # End of PSData hashtable

} # End of PrivateData hashtable
}