-
Notifications
You must be signed in to change notification settings - Fork 520
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
28136fd
commit 1f03788
Showing
7 changed files
with
243 additions
and
3 deletions.
There are no files selected for viewing
172 changes: 172 additions & 0 deletions
172
Modules/Office365DSC/DSCResources/MSFT_O365User/MSFT_O365User.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,172 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UserPrincipalName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$DisplayName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$FirstName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LastName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UsageLocation, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LicenseAssignment, | ||
|
||
[Parameter()] | ||
[System.Management.Automation.PSCredential] | ||
$Password, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Management.Automation.PSCredential] | ||
$GlobalAdminAccount | ||
) | ||
|
||
Test-O365ServiceConnection -GlobalAdminAccount $GlobalAdminAccount | ||
|
||
$nullReturn = @{ | ||
UserPrincipalName = $null | ||
DisplayName = $null | ||
FirstName = $null | ||
LastName = $null | ||
UsageLocation = $null | ||
LicenseAssignment = $null | ||
Password = $null | ||
} | ||
|
||
try { | ||
Write-Verbose -Message "Getting Office 365 User $UserPrincipalName" | ||
$user = Get-MSOLUser -UserPrincipalName $UserPrincipalName -ErrorAction SilentlyContinue | ||
if(!$user) | ||
{ | ||
Write-Verbose "The specified User doesn't already exist." | ||
return $nullReturn | ||
} | ||
$accountName = $user.LicenseAssignmentDetails.AccountSku.AccountName | ||
$sku = $user.LicenseAssignmentDetails.AccountSku.SkuPartNumber | ||
return @{ | ||
UserPrincipalName = $user.UserPrincipalName | ||
DisplayName = $user.DisplayName | ||
FirstName = $user.FirstName | ||
LastName = $user.LastName | ||
UsageLocation = $user.UsageLocation | ||
LicenseAssignment = $accountNAme + ":" + $sku | ||
Passsword = $Password | ||
} | ||
} | ||
catch { | ||
Write-Verbose "The specified User doesn't already exist." | ||
return $nullReturn | ||
} | ||
} | ||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UserPrincipalName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$DisplayName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$FirstName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LastName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UsageLocation, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LicenseAssignment, | ||
|
||
[Parameter()] | ||
[System.Management.Automation.PSCredential] | ||
$Password, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Management.Automation.PSCredential] | ||
$GlobalAdminAccount | ||
) | ||
|
||
Test-O365ServiceConnection -GlobalAdminAccount $GlobalAdminAccount | ||
|
||
Write-Verbose -Message "Setting Office 365 User $UserPrincipalName" | ||
$CurrentParameters = $PSBoundParameters | ||
$CurrentParameters.Remove("GlobalAdminAccount") | ||
|
||
New-MsolUser @CurrentParameters | ||
} | ||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UserPrincipalName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$DisplayName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$FirstName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LastName, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$UsageLocation, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$LicenseAssignment, | ||
|
||
[Parameter()] | ||
[System.Management.Automation.PSCredential] | ||
$Password, | ||
|
||
[Parameter(Mandatory = $true)] | ||
[System.Management.Automation.PSCredential] | ||
$GlobalAdminAccount | ||
) | ||
|
||
Write-Verbose -Message "Testing Office 365 User $UserPrincipalName" | ||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
return Test-Office365DSCParameterState -CurrentValues $CurrentValues ` | ||
-DesiredValues $PSBoundParameters ` | ||
-ValuesToCheck @("UserPrincipalName") | ||
} | ||
|
||
Export-ModuleMember -Function *-TargetResource |
13 changes: 13 additions & 0 deletions
13
Modules/Office365DSC/DSCResources/MSFT_O365User/MSFT_O365User.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,13 @@ | ||
[ClassVersion("1.0.0.0"), FriendlyName("O365User")] | ||
class MSFT_O365User : OMI_BaseResource | ||
{ | ||
[Key, Description("The login name of the user")] string UserPrincipalName; | ||
[Required, Description("The display name for the user")] string DisplayName; | ||
[Required, Description("The first name of the user")] string FirstName; | ||
[Required, Description("The last name of the user")] string LastName; | ||
[Required, Description("The country code the user will be assigned to")] string UsageLocation; | ||
[Required, Description("The account SKU Id for the license to be assigned to the user")] string LicenseAssignment; | ||
[Write, Description("The password for the account"), EmbeddedInstance("MSFT_Credential")] string Password; | ||
[Required, Description("Credentials of the SharePoint Global Admin"), EmbeddedInstance("MSFT_Credential")] string GlobalAdminAccount; | ||
}; | ||
|
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,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. |
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 |
---|---|---|
|
@@ -6,13 +6,25 @@ Configuration ProofOfConcept | |
{ | ||
SPOSite TestNik | ||
{ | ||
Url = "https://O365DSC1.sharepoint.com/sites/PoC6" | ||
Url = "https://O365DSC1.sharepoint.com/sites/PoC7" | ||
Owner = "[email protected]" | ||
StorageQuota = 100 | ||
ResourceQuota = 777 | ||
Title = "ProofOfConcept" | ||
CentralAdminUrl = "https://o365dsc1-admin.sharepoint.com" | ||
GlobalAdminAccount = $credsGlobalAdmin | ||
} | ||
|
||
O365User Bob | ||
{ | ||
UserPrincipalName = "[email protected]" | ||
FirstName = "Bob" | ||
LastName = "Houle" | ||
DisplayName = "Bob Houle" | ||
UsageLocation = "US" | ||
LicenseAssignment = "O365dsc1:ENTERPRISEPREMIUM" | ||
GlobalAdminAccount = $credsGlobalAdmin | ||
} | ||
} | ||
} | ||
|
||
|
Binary file not shown.
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
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