-
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 #115 from PowerShell/Release-v0.8
Releasing v0.8
- Loading branch information
Showing
78 changed files
with
4,851 additions
and
1,106 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
Modules/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.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,118 @@ | ||
function Get-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, | ||
[parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, | ||
[parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Getting antivirus configuration settings" | ||
|
||
$result = Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
try { | ||
$spFarm = Get-SPFarm | ||
} catch { | ||
Write-Verbose -Verbose "No local SharePoint farm was detected. Antivirus settings will not be applied" | ||
return $null | ||
} | ||
|
||
# Get a reference to the Administration WebService | ||
$admService = Get-xSharePointContentService | ||
|
||
return @{ | ||
# Set the antivirus settings | ||
AllowDownloadInfected = $admService.AntivirusSettings.AllowDownload | ||
ScanOnDownload = $admService.AntivirusSettings.DownloadScanEnabled | ||
ScanOnUpload = $admService.AntivirusSettings.UploadScanEnabled | ||
AttemptToClean = $admService.AntivirusSettings.CleaningEnabled | ||
NumberOfThreads = $admService.AntivirusSettings.NumberOfThreads | ||
TimeoutDuration = $admService.AntivirusSettings.Timeout.TotalSeconds | ||
InstallAccount = $params.InstallAccount | ||
} | ||
} | ||
|
||
return $result | ||
} | ||
|
||
|
||
function Set-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, | ||
[parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, | ||
[parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Setting antivirus configuration settings" | ||
|
||
Invoke-xSharePointCommand -Credential $InstallAccount -Arguments $PSBoundParameters -ScriptBlock { | ||
$params = $args[0] | ||
|
||
try { | ||
$spFarm = Get-SPFarm | ||
} catch { | ||
throw "No local SharePoint farm was detected. Antivirus settings will not be applied" | ||
return | ||
} | ||
|
||
Write-Verbose -Message "Start update" | ||
$admService = Get-xSharePointContentService | ||
|
||
# Set the antivirus settings | ||
if ($params.ContainsKey("AllowDownloadInfected")) { | ||
Write-Verbose -Message "Setting Allow Download" | ||
$admService.AntivirusSettings.AllowDownload = $params.AllowDownloadInfected | ||
} | ||
if ($params.ContainsKey("ScanOnDownload")) { $admService.AntivirusSettings.DownloadScanEnabled = $params.ScanOnDownload } | ||
if ($params.ContainsKey("ScanOnUpload")) { $admService.AntivirusSettings.UploadScanEnabled = $params.ScanOnUpload } | ||
if ($params.ContainsKey("AttemptToClean")) { $admService.AntivirusSettings.CleaningEnabled = $params.AttemptToClean } | ||
if ($params.ContainsKey("NumberOfThreads")) { $admService.AntivirusSettings.NumberOfThreads = $params.NumberOfThreads } | ||
if ($params.ContainsKey("TimeoutDuration")) { | ||
$timespan = New-TimeSpan -Seconds $params.TimeoutDuration | ||
$admService.AntivirusSettings.Timeout = $timespan | ||
} | ||
|
||
$admService.Update() | ||
} | ||
} | ||
|
||
|
||
function Test-TargetResource | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Boolean])] | ||
param | ||
( | ||
[parameter(Mandatory = $true)] [System.Boolean] $ScanOnDownload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $ScanOnUpload, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AllowDownloadInfected, | ||
[parameter(Mandatory = $false)] [System.Boolean] $AttemptToClean, | ||
[parameter(Mandatory = $false)] [System.UInt16] $TimeoutDuration, | ||
[parameter(Mandatory = $false)] [System.UInt16] $NumberOfThreads, | ||
[parameter(Mandatory = $false)] [System.Management.Automation.PSCredential] $InstallAccount | ||
) | ||
|
||
Write-Verbose -Message "Testing antivirus configuration settings" | ||
$CurrentValues = Get-TargetResource @PSBoundParameters | ||
|
||
if ($null -eq $CurrentValues) { return $false } | ||
|
||
return Test-xSharePointSpecificParameters -CurrentValues $CurrentValues -DesiredValues $PSBoundParameters | ||
} | ||
|
||
Export-ModuleMember -Function *-TargetResource |
30 changes: 30 additions & 0 deletions
30
...s/xSharePoint/DSCResources/MSFT_xSPAntivirusSettings/MSFT_xSPAntivirusSettings.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,30 @@ | ||
/* | ||
**Description** | ||
|
||
This resource is used to set the global antivirus settings for the local form. | ||
These settings will be used to control the behavior of an external anti-virus scanning tool that is able to integrate with SharePoint. | ||
Note that this will not scan documents for viruses on it's own, an external tool still needs to be installed on the servers that integrates with SharePoint. | ||
|
||
**Example** | ||
|
||
xSPAntivirusSettings AVSettings | ||
{ | ||
ScanOnDownload = $true | ||
ScanOnUpload = $true | ||
AllowDownloadInfected = $false | ||
AttemptToClean = $false | ||
} | ||
*/ | ||
|
||
[ClassVersion("1.0.0.0"), FriendlyName("xSPAntivirusSettings")] | ||
class MSFT_xSPAntivirusSettings : OMI_BaseResource | ||
{ | ||
[Key] Boolean ScanOnDownload; | ||
[Write] Boolean ScanOnUpload; | ||
[Write] Boolean AllowDownloadInfected; | ||
[Write] Boolean AttemptToClean; | ||
[Write] Uint16 TimeoutDuration; | ||
[Write] Uint16 NumberOfThreads; | ||
[Write, EmbeddedInstance("MSFT_Credential")] String InstallAccount; | ||
}; | ||
|
18 changes: 18 additions & 0 deletions
18
Modules/xSharePoint/DSCResources/MSFT_xSPBCSServiceApp/MSFT_xSPBCSServiceApp.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
14 changes: 14 additions & 0 deletions
14
Modules/xSharePoint/DSCResources/MSFT_xSPCacheAccounts/MSFT_xSPCacheAccounts.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
26 changes: 26 additions & 0 deletions
26
Modules/xSharePoint/DSCResources/MSFT_xSPCreateFarm/MSFT_xSPCreateFarm.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
30 changes: 30 additions & 0 deletions
30
...CResources/MSFT_xSPDiagnosticLoggingSettings/MSFT_xSPDiagnosticLoggingSettings.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
20 changes: 20 additions & 0 deletions
20
...t/DSCResources/MSFT_xSPDistributedCacheService/MSFT_xSPDistributedCacheService.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
Oops, something went wrong.